diff --git a/src/Form/ConfigSplitEntityForm.php b/src/Form/ConfigSplitEntityForm.php index 14200c0..250eee5 100644 --- a/src/Form/ConfigSplitEntityForm.php +++ b/src/Form/ConfigSplitEntityForm.php @@ -25,9 +25,25 @@ class ConfigSplitEntityForm extends EntityForm { public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); + // Fieldsets to organize included and excluded. + $form['settings'] = [ + '#type' => 'fieldset', + '#title' => $this->t('Split Settings'), + ]; + + $form['included'] = [ + '#type' => 'fieldset', + '#title' => $this->t('Included Configuration'), + ]; + + $form['excluded'] = [ + '#type' => 'fieldset', + '#title' => $this->t('Excluded Configuration'), + ]; + /** @var \Drupal\config_split\Entity\ConfigSplitEntityInterface $config */ $config = $this->entity; - $form['label'] = [ + $form['settings']['label'] = [ '#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, @@ -36,7 +52,7 @@ class ConfigSplitEntityForm extends EntityForm { '#required' => TRUE, ]; - $form['id'] = [ + $form['settings']['id'] = [ '#type' => 'machine_name', '#default_value' => $config->id(), '#machine_name' => [ @@ -45,21 +61,33 @@ class ConfigSplitEntityForm extends EntityForm { '#disabled' => !$config->isNew(), ]; - $form['folder'] = [ + $form['settings']['folder'] = [ '#type' => 'textfield', '#title' => $this->t('Folder'), '#description' => $this->t('The folder, relative to the Drupal root, to which to save the filtered config.
Configuration related to the "filtered" items below will be split from the main configuration and exported to this folder by drupal config_split:export.'), - '#maxlength' => 64, - '#size' => 64, '#default_value' => $config->get('folder'), ]; + $form['settings']['weight'] = [ + '#type' => 'number', + '#title' => $this->t('Weight'), + '#description' => $this->t('The weight to order the splits.'), + '#default_value' => $config->get('weight'), + ]; + + $form['settings']['status'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Active'), + '#description' => $this->t('Active splits get used by default, this property can be overwritten like any other config entity in settings.php.'), + '#default_value' => ($config->get('status') ? TRUE : FALSE), + ]; + // @TODO: Warn if there are extensions in $config that are not available. $module_handler = $this->moduleHandler; $modules = array_map(function ($module) use ($module_handler) { return $module_handler->getName($module->getName()); }, $module_handler->getModuleList()); - $form['module'] = [ + $form['included']['module'] = [ '#type' => 'select', '#title' => $this->t('Modules'), '#description' => $this->t('Select modules to filter.'), @@ -74,7 +102,7 @@ class ConfigSplitEntityForm extends EntityForm { $themes = array_map(function ($theme) use ($theme_handler) { return $theme_handler->getName($theme->getName()); }, $theme_handler->listInfo()); - $form['theme'] = [ + $form['included']['theme'] = [ '#type' => 'select', '#title' => $this->t('Themes'), '#description' => $this->t('Select themes to filter.'), @@ -84,71 +112,57 @@ class ConfigSplitEntityForm extends EntityForm { '#default_value' => array_keys($config->get('theme')), ]; // At this stage we do not support themes. @TODO: support themes. - $form['theme']['#access'] = FALSE; + $form['included']['theme']['#access'] = FALSE; $options = array_combine($this->configFactory()->listAll(), $this->configFactory()->listAll()); - $form['blacklist_select'] = [ + $form['included']['blacklist_select'] = [ '#type' => 'select', - '#title' => $this->t('Blacklist'), - '#description' => $this->t('Select configuration to filter.'), + '#title' => $this->t('Selected Configuration'), + '#description' => $this->t('Choose the list of configuration items to include.'), '#options' => $options, '#size' => 5, '#multiple' => TRUE, '#default_value' => array_intersect($config->get('blacklist'), array_keys($options)), ]; - $form['blacklist_text'] = [ + $form['included']['blacklist_text'] = [ '#type' => 'textarea', - '#title' => $this->t('Blacklist'), - '#description' => $this->t('Select additional configuration to filter. One configuration key per line.'), + '#title' => $this->t('Manually Specified Configuration'), + '#description' => $this->t('Define additional configuration to include, one configuration key per line.'), '#size' => 5, '#default_value' => implode("\n", array_diff($config->get('blacklist'), array_keys($options))), ]; - $form['graylist_select'] = [ + $form['excluded']['graylist_select'] = [ '#type' => 'select', - '#title' => $this->t('Graylist'), - '#description' => $this->t('Select configuration to ignore.'), + '#title' => $this->t('Selected Configuration'), + '#description' => $this->t('Choose the list of configuration items to ignore.'), '#options' => $options, '#size' => 5, '#multiple' => TRUE, '#default_value' => array_intersect($config->get('graylist'), array_keys($options)), ]; - $form['graylist_text'] = [ + $form['excluded']['graylist_text'] = [ '#type' => 'textarea', - '#title' => $this->t('Graylist'), - '#description' => $this->t('Select additional configuration to ignore. One configuration key per line.'), + '#title' => $this->t('Manually Specified Configuration'), + '#description' => $this->t('Define additional configuration to exclude, one configuration key per line.'), '#size' => 5, '#default_value' => implode("\n", array_diff($config->get('graylist'), array_keys($options))), ]; - $form['graylist_dependents'] = [ + $form['excluded']['graylist_dependents'] = [ '#type' => 'checkbox', - '#title' => $this->t('Include dependent configuration for graylist'), - '#description' => $this->t('If this is set, graylisted configuration will also include configuration that depend on it.'), + '#title' => $this->t('Dependent Configuration'), + '#description' => $this->t('Include dependent configuration for excluded configuration.'), '#default_value' => ($config->get('graylist_dependents') ? TRUE : FALSE), ]; - $form['graylist_skip_equal'] = [ + $form['excluded']['graylist_skip_equal'] = [ '#type' => 'checkbox', - '#title' => $this->t('Split graylist only when different'), - '#description' => $this->t('If this is set, graylisted configuration will not be in the split directory if it is equal to the one in the main sync directory.'), + '#title' => $this->t('Ignore Identical Configuration'), + '#description' => $this->t('If the config is the same between the sync and the split directory, it will be ignored.'), '#default_value' => ($config->get('graylist_skip_equal') ? TRUE : FALSE), ]; - $form['weight'] = [ - '#type' => 'number', - '#title' => $this->t('Weight'), - '#description' => $this->t('The weight to order the splits.'), - '#default_value' => $config->get('weight'), - ]; - - $form['status'] = [ - '#type' => 'checkbox', - '#title' => $this->t('Active'), - '#description' => $this->t('Active splits get used by default, this property can be overwritten like any other config entity in settings.php.'), - '#default_value' => ($config->get('status') ? TRUE : FALSE), - ]; - return $form; }