3 namespace Drupal\Core\Action;
5 use Drupal\Component\Plugin\CategorizingPluginManagerInterface;
6 use Drupal\Core\Cache\CacheBackendInterface;
7 use Drupal\Core\Extension\ModuleHandlerInterface;
8 use Drupal\Core\Plugin\CategorizingPluginManagerTrait;
9 use Drupal\Core\Plugin\DefaultPluginManager;
12 * Provides an Action plugin manager.
14 * @see \Drupal\Core\Annotation\Action
15 * @see \Drupal\Core\Action\ActionInterface
16 * @see \Drupal\Core\Action\ActionBase
19 class ActionManager extends DefaultPluginManager implements CategorizingPluginManagerInterface {
21 use CategorizingPluginManagerTrait;
24 * Constructs a new class instance.
26 * @param \Traversable $namespaces
27 * An object that implements \Traversable which contains the root paths
28 * keyed by the corresponding namespace to look for plugin implementations.
29 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
30 * Cache backend instance to use.
31 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
32 * The module handler to invoke the alter hook with.
34 public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
35 parent::__construct('Plugin/Action', $namespaces, $module_handler, 'Drupal\Core\Action\ActionInterface', 'Drupal\Core\Annotation\Action');
36 $this->alterInfo('action_info');
37 $this->setCacheBackend($cache_backend, 'action_info');
41 * Gets the plugin definitions for this entity type.
44 * The entity type name.
47 * An array of plugin definitions for this entity type.
49 public function getDefinitionsByType($type) {
50 return array_filter($this->getDefinitions(), function ($definition) use ($type) {
51 return $definition['type'] === $type;