composer_forced-8.x-1.3/composer_forced.module
composer_forced.module
<?php
/**
* @file
* Makes the install and update forms of the update module's UI unusable.
*/
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\composer_forced\ComposerForced;
/**
* Implements hook_form_FORM_ID_alter().
*/
function composer_forced_form_update_manager_update_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (!empty($form['projects'])) {
$form['projects']['#type'] = 'table';
$form['projects']['#rows'] = $form['projects']['#options'];
ComposerForced::cleanTableRows($form['projects']['#rows']);
$form['projects']['#options'] = [];
}
if (!empty($form['disabled_projects'])) {
$form['disabled_projects']['#type'] = 'table';
$form['disabled_projects']['#rows'] = $form['disabled_projects']['#options'];
ComposerForced::cleanTableRows($form['disabled_projects']['#rows']);
$form['disabled_projects']['#options'] = [];
}
// The following is unnecessary at the time of writing this comment but makes
// this module's code gap holes in case Drupal core allows automatic updates
// at some point in the future.
if (!empty($form['manual_updates']) && $form['manual_updates']['#type'] === 'tableselect') {
$form['manual_updates']['#type'] = 'table';
$form['manual_updates']['#rows'] = $form['manual_updates']['#options'];
ComposerForced::cleanTableRows($form['manual_updates']['#rows']);
$form['manual_updates']['#options'] = [];
}
if (!empty($form['actions'])) {
$form['actions']['#access'] = FALSE;
}
ComposerForced::replaceUpdateManagerUpdateForm($form);
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function composer_forced_form_update_manager_install_form_alter(&$form, FormStateInterface $form_state, $form_id) {
foreach (Element::children($form) as $key) {
if ($key !== 'help_text') {
$form[$key]['#access'] = FALSE;
}
}
ComposerForced::replaceUpdateManagerInstallForm($form);
}
