You are here

private function FlowForm::disableOverridenConfigs in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Form/FlowForm.php \Drupal\cms_content_sync\Form\FlowForm::disableOverridenConfigs()
  2. 2.0.x src/Form/FlowForm.php \Drupal\cms_content_sync\Form\FlowForm::disableOverridenConfigs()

Disable form elements which are overridden.

1 call to FlowForm::disableOverridenConfigs()
FlowForm::form in src/Form/FlowForm.php
Gets the actual form array to be built.

File

src/Form/FlowForm.php, line 2126

Class

FlowForm
Form handler for the Flow add and edit forms.

Namespace

Drupal\cms_content_sync\Form

Code

private function disableOverridenConfigs(array &$form) {
  global $config;
  $config_name = 'cms_content_sync.cms_content_sync.' . $form['id']['#default_value'];

  // If the default overrides aren't used check if a
  // master / subsite setting is used.
  if (!isset($config[$config_name]) || empty($config[$config_name])) {

    // Is this site a master site? It is a subsite by default.
    $environment = 'subsite';
    if ($this->configFactory
      ->get('config_split.config_split.cms_content_sync_master')
      ->get('status')) {
      $environment = 'master';
    }
    $config_name = 'cms_content_sync.sync.' . $environment;
  }
  $fields = Element::children($form);
  foreach ($fields as $field_key) {
    if ($this
      ->configIsOverridden($field_key, $config_name)) {
      $form[$field_key]['#disabled'] = 'disabled';
      $form[$field_key]['#value'] = $this->configFactory
        ->get($config_name)
        ->get($field_key);
      unset($form[$field_key]['#default_value']);
    }
  }
}