AliasTypeManager.php in View Mode Page 4.0.x
File
src/AliasTypeManager.php
View source
<?php
namespace Drupal\view_mode_page;
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/view_mode_page/AliasType', $namespaces, $module_handler, 'Drupal\\view_mode_page\\AliasTypeInterface', 'Drupal\\view_mode_page\\Annotation\\AliasType');
$this
->setCacheBackend($cache_backend, 'view_mode_page_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;
}
}