You are here

protected function WebformAdminConfigBaseForm::buildExcludedPlugins in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Form/AdminConfig/WebformAdminConfigBaseForm.php \Drupal\webform\Form\AdminConfig\WebformAdminConfigBaseForm::buildExcludedPlugins()

Build excluded plugins element.

Parameters

\Drupal\Component\Plugin\PluginManagerInterface $plugin_manager: A webform element, handler, or exporter plugin manager.

array $excluded_ids: An array of excluded ids.

Return value

array A table select element used to excluded plugins by id.

4 calls to WebformAdminConfigBaseForm::buildExcludedPlugins()
WebformAdminConfigElementsForm::buildForm in src/Form/AdminConfig/WebformAdminConfigElementsForm.php
Form constructor.
WebformAdminConfigExportersForm::buildForm in src/Form/AdminConfig/WebformAdminConfigExportersForm.php
Form constructor.
WebformAdminConfigHandlersForm::buildForm in src/Form/AdminConfig/WebformAdminConfigHandlersForm.php
Form constructor.
WebformAdminConfigVariantsForm::buildForm in src/Form/AdminConfig/WebformAdminConfigVariantsForm.php
Form constructor.

File

src/Form/AdminConfig/WebformAdminConfigBaseForm.php, line 146

Class

WebformAdminConfigBaseForm
Base webform admin settings form.

Namespace

Drupal\webform\Form\AdminConfig

Code

protected function buildExcludedPlugins(PluginManagerInterface $plugin_manager, array $excluded_ids) {
  $header = [
    'title' => [
      'data' => $this
        ->t('Title'),
    ],
    'id' => [
      'data' => $this
        ->t('Name'),
      'class' => [
        RESPONSIVE_PRIORITY_LOW,
      ],
    ],
    'description' => [
      'data' => $this
        ->t('Description'),
      'class' => [
        RESPONSIVE_PRIORITY_LOW,
      ],
    ],
  ];
  $ids = [];
  $options = [];
  $plugins = $this
    ->getPluginDefinitions($plugin_manager);
  foreach ($plugins as $id => $plugin_definition) {
    $ids[$id] = $id;
    $description = [
      'data' => [
        'content' => [
          '#markup' => $plugin_definition['description'],
        ],
      ],
    ];
    if (!empty($plugin_definition['deprecated'])) {
      $description['data']['deprecated'] = [
        '#type' => 'webform_message',
        '#message_message' => $plugin_definition['deprecated_message'],
        '#message_type' => 'warning',
      ];
    }
    $options[$id] = [
      'title' => $plugin_definition['label'],
      'id' => $plugin_definition['id'],
      'description' => $description,
    ];
  }
  $element = [
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#required' => TRUE,
    '#sticky' => TRUE,
    '#default_value' => array_diff($ids, $excluded_ids),
  ];
  TableSelect::setProcessTableSelectCallback($element);
  return $element;
}