public function ModulesListConfirmForm::buildForm in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/system/src/Form/ModulesListConfirmForm.php \Drupal\system\Form\ModulesListConfirmForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfirmFormBase::buildForm
File
- core/
modules/ system/ src/ Form/ ModulesListConfirmForm.php, line 118 - Contains \Drupal\system\Form\ModulesListConfirmForm.
Class
- ModulesListConfirmForm
- Builds a confirmation form for enabling modules with dependencies.
Namespace
Drupal\system\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$account = $this
->currentUser()
->id();
$this->modules = $this->keyValueExpirable
->get($account);
// Redirect to the modules list page if the key value store is empty.
if (!$this->modules) {
return $this
->redirect('system.modules_list');
}
$items = array();
// Display a list of required modules that have to be installed as well but
// were not manually selected.
foreach ($this->modules['dependencies'] as $module => $dependencies) {
$items[] = $this
->formatPlural(count($dependencies), 'You must enable the @required module to install @module.', 'You must enable the @required modules to install @module.', array(
'@module' => $this->modules['install'][$module],
'@required' => implode(', ', $dependencies),
));
}
$form['message'] = array(
'#theme' => 'item_list',
'#items' => $items,
);
return parent::buildForm($form, $form_state);
}