public function AssignmentExcludeForm::buildForm in Features 8.4
Same name and namespace in other branches
- 8.3 modules/features_ui/src/Form/AssignmentExcludeForm.php \Drupal\features_ui\Form\AssignmentExcludeForm::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 FormInterface::buildForm
File
- modules/
features_ui/ src/ Form/ AssignmentExcludeForm.php, line 78
Class
- AssignmentExcludeForm
- Configures the selected configuration assignment method for this site.
Namespace
Drupal\features_ui\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $bundle_name = NULL) {
$this->currentBundle = $this->assigner
->loadBundle($bundle_name);
$settings = $this->currentBundle
->getAssignmentSettings(self::METHOD_ID);
$module_settings = $settings['module'];
$curated_settings = $settings['curated'];
$this
->setConfigTypeSelect($form, $settings['types']['config'], $this
->t('exclude'), FALSE, $this
->t("Select types of configuration that should be excluded from packaging."));
$form['curated'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Exclude designated site-specific configuration'),
'#default_value' => $curated_settings,
'#description' => $this
->t('Select this option to exclude a curated list of site-specific configuration from packaging.'),
];
$form['module'] = [
'#type' => 'fieldset',
'#tree' => TRUE,
'#title' => $this
->t('Exclude configuration provided by modules'),
];
$form['module']['installed'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Exclude installed module-provided entity configuration'),
'#default_value' => $module_settings['installed'],
'#description' => $this
->t('Select this option to exclude configuration provided by INSTALLED modules from reassignment.'),
'#attributes' => [
'data-module-installed' => 'status',
],
];
$show_if_module_installed_checked = [
'visible' => [
':input[data-module-installed="status"]' => [
'checked' => TRUE,
],
],
];
$info = $this->profileList
->getExtensionInfo($this->installProfile);
$form['module']['profile'] = [
'#type' => 'checkbox',
'#title' => $this
->t("Don't exclude install profile's configuration"),
'#default_value' => $module_settings['profile'],
'#description' => $this
->t("Select this option to allow configuration provided by the site's install profile (%profile) to be reassigned.", [
'%profile' => $info['name'],
]),
'#states' => $show_if_module_installed_checked,
];
$bundle_name = $this->currentBundle
->getMachineName();
$bundle_name = !empty($bundle_name) ? $bundle_name : $this
->t('none');
$form['module']['namespace'] = [
'#type' => 'checkbox',
'#title' => $this
->t("Don't exclude non-installed configuration by namespace"),
'#default_value' => $module_settings['namespace'],
'#description' => $this
->t("Select this option to allow configuration provided by uninstalled modules with the bundle namespace (%namespace_*) to be reassigned.", [
'%namespace' => $bundle_name,
]),
'#states' => $show_if_module_installed_checked,
'#attributes' => [
'data-namespace' => 'status',
],
];
$show_if_namespace_checked = [
'visible' => [
':input[data-namespace="status"]' => [
'checked' => TRUE,
],
':input[data-module-installed="status"]' => [
'checked' => TRUE,
],
],
];
$form['module']['namespace_any'] = [
'#type' => 'checkbox',
'#title' => $this
->t("Don't exclude ANY configuration by namespace"),
'#default_value' => $module_settings['namespace_any'],
'#description' => $this
->t("Select this option to allow configuration provided by ANY modules with the bundle namespace (%namespace_*) to be reassigned.\n Warning: Can cause installed configuration to be reassigned to different packages.", [
'%namespace' => $bundle_name,
]),
'#states' => $show_if_namespace_checked,
];
$this
->setActions($form, self::METHOD_ID);
return $form;
}