class ListPluginTypes in Plugin 8.2
Handles the "list plugin types" route.
Hierarchy
- class \Drupal\plugin\Controller\ListBase implements ContainerInjectionInterface uses StringTranslationTrait- class \Drupal\plugin\Controller\ListPluginTypes
 
Expanded class hierarchy of ListPluginTypes
1 file declares its use of ListPluginTypes
- ListPluginTypesTest.php in tests/src/ Unit/ Controller/ ListPluginTypesTest.php 
File
- src/Controller/ ListPluginTypes.php, line 14 
Namespace
Drupal\plugin\ControllerView source
class ListPluginTypes extends ListBase {
  /**
   * The plugin type manager.
   *
   * @var \Drupal\plugin\PluginType\PluginTypeManagerInterface
   */
  protected $pluginTypeManager;
  /**
   * Constructs a new instance.
   *
   * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
   *   The string translator.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   * @param \Drupal\plugin\PluginType\PluginTypeManagerInterface
   *   The plugin type manager.
   */
  public function __construct(TranslationInterface $string_translation, ModuleHandlerInterface $module_handler, PluginTypeManagerInterface $plugin_type_manager) {
    parent::__construct($string_translation, $module_handler);
    $this->pluginTypeManager = $plugin_type_manager;
  }
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('string_translation'), $container
      ->get('module_handler'), $container
      ->get('plugin.plugin_type_manager'));
  }
  /**
   * Handles the route.
   *
   * @return mixed[]
   *   A render array.
   */
  public function execute() {
    $build = [
      '#empty' => $this
        ->t('There are no available plugin types.'),
      '#header' => [
        $this
          ->t('Type'),
        $this
          ->t('Description'),
        $this
          ->t('Provider'),
        $this
          ->t('Operations'),
      ],
      '#type' => 'table',
    ];
    $plugin_types = $this->pluginTypeManager
      ->getPluginTypes();
    uasort($plugin_types, function (PluginTypeInterface $plugin_type_a, PluginTypeInterface $plugin_type_b) {
      return strnatcasecmp($plugin_type_a
        ->getLabel(), $plugin_type_b
        ->getLabel());
    });
    foreach ($plugin_types as $plugin_type_id => $plugin_type) {
      $operations_provider = $plugin_type
        ->getOperationsProvider();
      $operations = $operations_provider ? $operations_provider
        ->getOperations($plugin_type_id) : [];
      $build[$plugin_type_id]['label'] = [
        '#markup' => $plugin_type
          ->getLabel(),
      ];
      $build[$plugin_type_id]['description'] = [
        '#markup' => $plugin_type
          ->getDescription(),
      ];
      $build[$plugin_type_id]['provider'] = [
        '#markup' => $this
          ->getProviderLabel($plugin_type
          ->getProvider()),
      ];
      $build[$plugin_type_id]['operations'] = [
        '#links' => $operations,
        '#type' => 'operations',
      ];
    }
    return $build;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| ListBase:: | protected | property | The module handler. | |
| ListBase:: | protected | function | Gets the human-readable provider label. | |
| ListPluginTypes:: | protected | property | The plugin type manager. | |
| ListPluginTypes:: | public static | function | Instantiates a new instance of this class. Overrides ListBase:: | |
| ListPluginTypes:: | public | function | Handles the route. | |
| ListPluginTypes:: | public | function | Constructs a new instance. Overrides ListBase:: | |
| StringTranslationTrait:: | protected | property | The string translation service. | 1 | 
| StringTranslationTrait:: | protected | function | Formats a string containing a count of items. | |
| StringTranslationTrait:: | protected | function | Returns the number of plurals supported by a given language. | |
| StringTranslationTrait:: | protected | function | Gets the string translation service. | |
| StringTranslationTrait:: | public | function | Sets the string translation service to use. | 2 | 
| StringTranslationTrait:: | protected | function | Translates a string to the current language or to a given language. | 
