class TopBarItemManager
Same name and namespace in other branches
- 11.x core/modules/navigation/src/TopBarItemManager.php \Drupal\navigation\TopBarItemManager
Top bar item plugin manager.
Hierarchy
- class \Drupal\Component\Plugin\PluginManagerBase implements \Drupal\Component\Plugin\PluginManagerInterface uses \Drupal\Component\Plugin\Discovery\DiscoveryTrait
- class \Drupal\Core\Plugin\DefaultPluginManager implements \Drupal\Component\Plugin\PluginManagerInterface, \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface, \Drupal\Core\Cache\CacheableDependencyInterface uses \Drupal\Component\Plugin\Discovery\DiscoveryCachedTrait, \Drupal\Core\Cache\UseCacheBackendTrait extends \Drupal\Component\Plugin\PluginManagerBase
- class \Drupal\navigation\TopBarItemManager implements \Drupal\navigation\TopBarItemManagerInterface extends \Drupal\Core\Plugin\DefaultPluginManager
- class \Drupal\Core\Plugin\DefaultPluginManager implements \Drupal\Component\Plugin\PluginManagerInterface, \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface, \Drupal\Core\Cache\CacheableDependencyInterface uses \Drupal\Component\Plugin\Discovery\DiscoveryCachedTrait, \Drupal\Core\Cache\UseCacheBackendTrait extends \Drupal\Component\Plugin\PluginManagerBase
Expanded class hierarchy of TopBarItemManager
1 file declares its use of TopBarItemManager
- TopBarItemManagerTest.php in core/
modules/ navigation/ tests/ src/ Unit/ TopBarItemManagerTest.php
1 string reference to 'TopBarItemManager'
- navigation.services.yml in core/
modules/ navigation/ navigation.services.yml - core/modules/navigation/navigation.services.yml
1 service uses TopBarItemManager
- plugin.manager.top_bar_item in core/
modules/ navigation/ navigation.services.yml - Drupal\navigation\TopBarItemManager
File
-
core/
modules/ navigation/ src/ TopBarItemManager.php, line 15
Namespace
Drupal\navigationView source
final class TopBarItemManager extends DefaultPluginManager implements TopBarItemManagerInterface {
/**
* Constructs the object.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/TopBarItem', $namespaces, $module_handler, TopBarItemPluginInterface::class, TopBarItem::class);
$this->alterInfo('top_bar_item');
$this->setCacheBackend($cache_backend, 'top_bar_item_plugins');
}
/**
* {@inheritdoc}
*/
public function getDefinitionsByRegion(TopBarRegion $region) : array {
return array_filter($this->getDefinitions(), fn(array $definition) => $definition['region'] === $region);
}
/**
* {@inheritdoc}
*/
public function getRenderedTopBarItemsByRegion(TopBarRegion $region) : array {
$instances = [];
foreach ($this->getDefinitionsByRegion($region) as $plugin_id => $plugin_definition) {
$instances[$plugin_id] = $this->createInstance($plugin_id)
->build();
}
return $instances;
}
/**
* {@inheritdoc}
*/
public function getDefinitions() : array {
$definitions = parent::getDefinitions();
// Sort definitions by weight.
uasort($definitions, function (array $a, array $b) {
return ($a['weight'] ?? 0) <=> ($b['weight'] ?? 0);
});
return $definitions;
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
|---|---|---|---|---|
| DefaultPluginManager::$additionalAnnotationNamespaces | protected | property | Additional annotation namespaces. | |
| DefaultPluginManager::$alterHook | protected | property | Name of the alter hook if one should be invoked. | |
| DefaultPluginManager::$cacheKey | protected | property | The cache key. | |
| DefaultPluginManager::$cacheTags | protected | property | An array of cache tags to use for the cached definitions. | |
| DefaultPluginManager::$defaults | protected | property | A set of defaults to be referenced by $this->processDefinition(). | |
| DefaultPluginManager::$moduleExtensionList | protected | property | The module extension list. | |
| DefaultPluginManager::$moduleHandler | protected | property | The module handler to invoke the alter hook. | |
| DefaultPluginManager::$namespaces | protected | property | An object of root paths that are traversable. | |
| DefaultPluginManager::$pluginDefinitionAnnotationName | protected | property | The name of the annotation that contains the plugin definition. | |
| DefaultPluginManager::$pluginDefinitionAttributeName | protected | property | The name of the attribute that contains the plugin definition. | |
| DefaultPluginManager::$pluginInterface | protected | property | The interface each plugin should implement. | |
| DefaultPluginManager::$subdir | protected | property | The subdirectory within a namespace to look for plugins. | |
| DefaultPluginManager::alterDefinitions | protected | function | Invokes the hook to alter the definitions if the alter hook is set. | |
| DefaultPluginManager::alterInfo | protected | function | Sets the alter hook name. | |
| DefaultPluginManager::clearCachedDefinitions | public | function | ||
| DefaultPluginManager::extractProviderFromDefinition | protected | function | Extracts the provider from a plugin definition. | |
| DefaultPluginManager::findDefinitions | protected | function | Finds plugin definitions. | |
| DefaultPluginManager::getCacheContexts | public | function | ||
| DefaultPluginManager::getCachedDefinitions | protected | function | Returns the cached plugin definitions of the decorated discovery class. | |
| DefaultPluginManager::getCacheMaxAge | public | function | ||
| DefaultPluginManager::getCacheTags | public | function | ||
| DefaultPluginManager::getDiscovery | protected | function | ||
| DefaultPluginManager::getFactory | protected | function | ||
| DefaultPluginManager::processDefinition | public | function | Performs extra processing on plugin definitions. | |
| DefaultPluginManager::providerExists | protected | function | Determines if the provider of a definition exists. | |
| DefaultPluginManager::setCacheBackend | public | function | Initialize the cache backend. | |
| DefaultPluginManager::setCachedDefinitions | protected | function | Sets a cache of plugin definitions for the decorated discovery class. | |
| DefaultPluginManager::useCaches | public | function | ||
| DiscoveryCachedTrait::$definitions | protected | property | Cached definitions array. | |
| DiscoveryCachedTrait::getDefinition | public | function | ||
| DiscoveryTrait::doGetDefinition | protected | function | Gets a specific plugin definition. | |
| DiscoveryTrait::hasDefinition | public | function | ||
| PluginManagerBase::$discovery | protected | property | The object that discovers plugins managed by this manager. | |
| PluginManagerBase::$factory | protected | property | The object that instantiates plugins managed by this manager. | |
| PluginManagerBase::$mapper | protected | property | The preconfigured plugin instance for a particular runtime condition. | |
| PluginManagerBase::createInstance | public | function | ||
| PluginManagerBase::getFallbackPluginId | protected | function | Gets a fallback id for a missing plugin. | |
| PluginManagerBase::getInstance | public | function | ||
| PluginManagerBase::handlePluginNotFound | protected | function | Allows plugin managers to specify custom behavior if a plugin is not found. | |
| TopBarItemManager::getDefinitions | public | function | Gets the definition of all plugins for this type. | Overrides DefaultPluginManager::getDefinitions |
| TopBarItemManager::getDefinitionsByRegion | public | function | Gets the top bar item plugins by region. | Overrides TopBarItemManagerInterface::getDefinitionsByRegion |
| TopBarItemManager::getRenderedTopBarItemsByRegion | public | function | Gets the top bar items prepared as render array. | Overrides TopBarItemManagerInterface::getRenderedTopBarItemsByRegion |
| TopBarItemManager::__construct | public | function | Constructs the object. | Overrides DefaultPluginManager::__construct |
| UseCacheBackendTrait::$cacheBackend | protected | property | Cache backend instance. | |
| UseCacheBackendTrait::$useCaches | protected | property | Flag whether caches should be used or skipped. | |
| UseCacheBackendTrait::cacheGet | protected | function | Fetches from the cache backend, respecting the use caches flag. | |
| UseCacheBackendTrait::cacheSet | protected | function | Stores data in the persistent cache, respecting the use caches flag. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.