You are here

public function FlowForm::enableAllReferenced in CMS Content Sync 2.0.x

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

Show all field settings not just the summary.

Parameters

array $form:

File

src/Form/FlowForm.php, line 442

Class

FlowForm
Form handler for the Flow add and edit forms.

Namespace

Drupal\cms_content_sync\Form

Code

public function enableAllReferenced($form, FormStateInterface $form_state) {
  $trigger = $form_state
    ->getTriggeringElement();
  $type_key = $trigger['#entity_type'];
  $entity_bundle_name = $trigger['#bundle'];
  $this->triggeringType = $type_key;
  $this->triggeringBundle = $entity_bundle_name;
  $this->triggeredAction = 'fields';
  $this
    ->fixMissingFormStateFromAjax($form, $form_state);
  $referenced_type = $trigger['#referenced_type'];
  $referenced_bundles = $trigger['#referenced_bundles'];
  if ('all' === $referenced_bundles) {
    $entity_types = $this->bundleInfoService
      ->getAllBundleInfo();
    foreach ($entity_types[$referenced_type] as $bundle => $set) {
      if (empty($current_values['sync_entities'][$referenced_type . '-' . $bundle]['handler']) || Flow::HANDLER_IGNORE == $current_values['sync_entities'][$referenced_type . '-' . $bundle]['handler']) {
        $form_state
          ->setValue([
          $referenced_type,
          $bundle,
          'edit',
        ], '1');
        $this->ajaxReplaceElements[] = [
          $referenced_type,
          $bundle,
        ];
      }
    }
  }
  else {
    foreach ($referenced_bundles as $bundle) {
      if (empty($current_values['sync_entities'][$referenced_type . '-' . $bundle]['handler']) || Flow::HANDLER_IGNORE == $current_values['sync_entities'][$referenced_type . '-' . $bundle]['handler']) {
        $form_state
          ->setValue([
          $referenced_type,
          $bundle,
          'edit',
        ], '1');
        $this->ajaxReplaceElements[] = [
          $referenced_type,
          $bundle,
        ];
      }
    }
  }
  $form_state
    ->setRebuild();
}