You are here

protected function FlowForm::renderDisabledBundle 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::renderDisabledBundle()
  2. 2.0.x src/Form/FlowForm.php \Drupal\cms_content_sync\Form\FlowForm::renderDisabledBundle()

The bundle isn't pushed or pulled right now. The user can enable it with a button then.

Parameters

$type_key:

$entity_bundle_name:

Return value

array

1 call to FlowForm::renderDisabledBundle()
FlowForm::renderEntityType in src/Form/FlowForm.php
Render all bundles for the given entity type. Displayed in vertical tabs from the parent form.

File

src/Form/FlowForm.php, line 1888

Class

FlowForm
Form handler for the Flow add and edit forms.

Namespace

Drupal\cms_content_sync\Form

Code

protected function renderDisabledBundle(FormStateInterface $form_state, $type_key, $entity_bundle_name) {
  $entity_types = $this->bundleInfoService
    ->getAllBundleInfo();
  $entity_bundle = $entity_types[$type_key][$entity_bundle_name];
  $bundle_id = $type_key . '-' . $entity_bundle_name;
  $settings_id = 'sync-entities-' . $bundle_id;
  $bundle_info = [
    '#prefix' => '<div id="' . $settings_id . '">',
    '#suffix' => '</div>',
    '#markup' => '<h2>' . $this
      ->t('@bundle (@machine_name)', [
      '@bundle' => $entity_bundle['label'],
      '@machine_name' => $entity_bundle_name,
    ]) . '</h2>',
  ];
  $entity_handlers = $this->entityPluginManager
    ->getHandlerOptions($type_key, $entity_bundle_name, true);
  if (empty($entity_handlers)) {
    $bundle_info['#markup'] .= '<p>This entity type / bundle is not supported.</p>';
  }
  else {
    $bundle_info['handler'] = [
      '#type' => 'hidden',
      '#value' => 'ignore',
    ];
    $bundle_info['edit'] = [
      '#type' => 'hidden',
      '#value' => '0',
    ];
    $title = $this
      ->t('Enable');
    $bundle_info['enable'] = [
      '#type' => 'submit',
      '#value' => $title,
      '#name' => 'enable-' . $type_key . '-' . $entity_bundle_name,
      '#submit' => [
        '::enableBundle',
      ],
      '#entity_type' => $type_key,
      '#bundle' => $entity_bundle_name,
      '#limit_validation_errors' => [],
      '#attributes' => [
        'class' => [
          'button--primary',
        ],
      ],
      '#ajax' => [
        'callback' => '::ajaxReturn',
        'wrapper' => $settings_id,
        'method' => 'replace',
        'effect' => 'fade',
        'progress' => [
          'type' => 'throbber',
          'message' => 'loading settings...',
        ],
      ],
    ];
  }
  return $bundle_info;
}