Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Core\Action;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Component\Plugin\CategorizingPluginManagerInterface;
|
Chris@0
|
6 use Drupal\Core\Cache\CacheBackendInterface;
|
Chris@0
|
7 use Drupal\Core\Extension\ModuleHandlerInterface;
|
Chris@0
|
8 use Drupal\Core\Plugin\CategorizingPluginManagerTrait;
|
Chris@0
|
9 use Drupal\Core\Plugin\DefaultPluginManager;
|
Chris@0
|
10
|
Chris@0
|
11 /**
|
Chris@0
|
12 * Provides an Action plugin manager.
|
Chris@0
|
13 *
|
Chris@0
|
14 * @see \Drupal\Core\Annotation\Action
|
Chris@0
|
15 * @see \Drupal\Core\Action\ActionInterface
|
Chris@0
|
16 * @see \Drupal\Core\Action\ActionBase
|
Chris@0
|
17 * @see plugin_api
|
Chris@0
|
18 */
|
Chris@0
|
19 class ActionManager extends DefaultPluginManager implements CategorizingPluginManagerInterface {
|
Chris@0
|
20
|
Chris@0
|
21 use CategorizingPluginManagerTrait;
|
Chris@0
|
22
|
Chris@0
|
23 /**
|
Chris@0
|
24 * Constructs a new class instance.
|
Chris@0
|
25 *
|
Chris@0
|
26 * @param \Traversable $namespaces
|
Chris@0
|
27 * An object that implements \Traversable which contains the root paths
|
Chris@0
|
28 * keyed by the corresponding namespace to look for plugin implementations.
|
Chris@0
|
29 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
|
Chris@0
|
30 * Cache backend instance to use.
|
Chris@0
|
31 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
Chris@0
|
32 * The module handler to invoke the alter hook with.
|
Chris@0
|
33 */
|
Chris@0
|
34 public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
|
Chris@0
|
35 parent::__construct('Plugin/Action', $namespaces, $module_handler, 'Drupal\Core\Action\ActionInterface', 'Drupal\Core\Annotation\Action');
|
Chris@0
|
36 $this->alterInfo('action_info');
|
Chris@0
|
37 $this->setCacheBackend($cache_backend, 'action_info');
|
Chris@0
|
38 }
|
Chris@0
|
39
|
Chris@0
|
40 /**
|
Chris@0
|
41 * Gets the plugin definitions for this entity type.
|
Chris@0
|
42 *
|
Chris@0
|
43 * @param string $type
|
Chris@0
|
44 * The entity type name.
|
Chris@0
|
45 *
|
Chris@0
|
46 * @return array
|
Chris@0
|
47 * An array of plugin definitions for this entity type.
|
Chris@0
|
48 */
|
Chris@0
|
49 public function getDefinitionsByType($type) {
|
Chris@0
|
50 return array_filter($this->getDefinitions(), function ($definition) use ($type) {
|
Chris@0
|
51 return $definition['type'] === $type;
|
Chris@0
|
52 });
|
Chris@0
|
53 }
|
Chris@0
|
54
|
Chris@0
|
55 }
|