comparison core/lib/Drupal/Core/Action/ActionManager.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Core\Action;
4
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;
10
11 /**
12 * Provides an Action plugin manager.
13 *
14 * @see \Drupal\Core\Annotation\Action
15 * @see \Drupal\Core\Action\ActionInterface
16 * @see \Drupal\Core\Action\ActionBase
17 * @see plugin_api
18 */
19 class ActionManager extends DefaultPluginManager implements CategorizingPluginManagerInterface {
20
21 use CategorizingPluginManagerTrait;
22
23 /**
24 * Constructs a new class instance.
25 *
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.
33 */
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');
38 }
39
40 /**
41 * Gets the plugin definitions for this entity type.
42 *
43 * @param string $type
44 * The entity type name.
45 *
46 * @return array
47 * An array of plugin definitions for this entity type.
48 */
49 public function getDefinitionsByType($type) {
50 return array_filter($this->getDefinitions(), function ($definition) use ($type) {
51 return $definition['type'] === $type;
52 });
53 }
54
55 }