AliasTypeManager.php in Pathauto 8
File
src/AliasTypeManager.php
View source
<?php
namespace Drupal\pathauto;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Component\Plugin\FallbackPluginManagerInterface;
class AliasTypeManager extends DefaultPluginManager implements FallbackPluginManagerInterface {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/pathauto/AliasType', $namespaces, $module_handler, 'Drupal\\pathauto\\AliasTypeInterface', 'Drupal\\pathauto\\Annotation\\AliasType');
$this
->alterInfo('pathauto_alias_types');
$this
->setCacheBackend($cache_backend, 'pathauto_alias_types');
}
public function getPluginDefinitionByType($type) {
$definitions = array_filter($this
->getDefinitions(), function ($definition) use ($type) {
if (!empty($definition['types']) && in_array($type, $definition['types'])) {
return TRUE;
}
return FALSE;
});
return $definitions;
}
public function getFallbackPluginId($plugin_id, array $configuration = []) {
return 'broken';
}
public function getVisibleDefinitions() {
$definitions = $this
->getDefinitions();
unset($definitions['broken']);
return $definitions;
}
}