You are here

public function ExtraFieldPluginListController::pluginsList in Extra Field Settings Provider 8

Same name and namespace in other branches
  1. 8.2 src/Controller/ExtraFieldPluginListController.php \Drupal\extra_field_plus\Controller\ExtraFieldPluginListController::pluginsList()

Provides extra field plugins list.

1 string reference to 'ExtraFieldPluginListController::pluginsList'
extra_field_plus.routing.yml in ./extra_field_plus.routing.yml
extra_field_plus.routing.yml

File

src/Controller/ExtraFieldPluginListController.php, line 55

Class

ExtraFieldPluginListController
Class ExtraFieldPluginListController.

Namespace

Drupal\extra_field_plus\Controller

Code

public function pluginsList() {
  $row = [];
  $definitions = $this->pluginManager
    ->getDefinitions();
  if (ksort($definitions)) {
    foreach ($definitions as $plugin_id => $definition) {
      $class = explode('\\', $definition['class']);
      $settings = $this->pluginFormManager
        ->hasSettingsForm($plugin_id);
      $row[] = [
        [
          'data' => $plugin_id,
        ],
        [
          'data' => $definition['label'],
        ],
        [
          'data' => [
            '#markup' => implode('<br/>', $definition['bundles']),
          ],
        ],
        [
          'data' => end($class),
        ],
        [
          'data' => $definition['provider'],
        ],
        [
          'data' => $settings ? $this
            ->t('Yes') : $this
            ->t('No'),
        ],
      ];
    }
  }
  $elements = [
    '#type' => 'table',
    '#sticky' => TRUE,
    '#empty' => $this
      ->t('Fields list is empty.'),
    '#header' => [
      [
        'data' => $this
          ->t('Id'),
      ],
      [
        'data' => $this
          ->t('Label'),
      ],
      [
        'data' => $this
          ->t('Bundles'),
      ],
      [
        'data' => $this
          ->t('Class'),
      ],
      [
        'data' => $this
          ->t('Provider'),
      ],
      [
        'data' => $this
          ->t('Settings'),
      ],
    ],
    '#rows' => $row,
  ];
  return $elements;
}