3 namespace Drupal\pathauto;
5 use Drupal\Core\Cache\CacheBackendInterface;
6 use Drupal\Core\Extension\ModuleHandlerInterface;
7 use Drupal\Core\Plugin\DefaultPluginManager;
8 use Drupal\Component\Plugin\FallbackPluginManagerInterface;
11 * Manages pathauto alias type plugins.
13 class AliasTypeManager extends DefaultPluginManager implements FallbackPluginManagerInterface {
16 * Constructs a new AliasType manager instance.
18 * @param \Traversable $namespaces
19 * An object that implements \Traversable which contains the root paths
20 * keyed by the corresponding namespace to look for plugin implementations.
21 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
22 * Cache backend instance to use.
23 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
24 * The module handler to invoke the alter hook with.
26 public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
27 parent::__construct('Plugin/pathauto/AliasType', $namespaces, $module_handler, 'Drupal\pathauto\AliasTypeInterface', 'Drupal\pathauto\Annotation\AliasType');
28 $this->alterInfo('pathauto_alias_types');
29 $this->setCacheBackend($cache_backend, 'pathauto_alias_types');
33 * Returns plugin definitions that support a given token type.
36 * The type of token plugin must support to be useful.
41 public function getPluginDefinitionByType($type) {
42 $definitions = array_filter($this->getDefinitions(), function ($definition) use ($type) {
43 if (!empty($definition['types']) && in_array($type, $definition['types'])) {
54 public function getFallbackPluginId($plugin_id, array $configuration = array()) {
59 * Gets the definition of all visible plugins for this type.
62 * An array of plugin definitions (empty array if no definitions were
63 * found). Keys are plugin IDs.
65 public function getVisibleDefinitions() {
66 $definitions = $this->getDefinitions();
67 unset($definitions['broken']);