LinkRelationTypeManager.php
Same filename in other branches
Namespace
Drupal\Core\HttpFile
-
core/
lib/ Drupal/ Core/ Http/ LinkRelationTypeManager.php
View source
<?php
namespace Drupal\Core\Http;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Plugin\Discovery\YamlDiscovery;
/**
* Provides a default plugin manager for link relation types.
*
* @see \Drupal\Core\Http\LinkRelationTypeInterface
*/
class LinkRelationTypeManager extends DefaultPluginManager {
/**
* {@inheritdoc}
*/
protected $defaults = [
'class' => LinkRelationType::class,
];
/**
* The app root.
*
* @var string
*/
protected $root;
/**
* Constructs a new LinkRelationTypeManager.
*
* @param string $root
* The app root.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* The cache backend.
*/
public function __construct($root, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache) {
$this->root = $root;
$this->pluginInterface = LinkRelationTypeInterface::class;
$this->moduleHandler = $module_handler;
$this->setCacheBackend($cache, 'link_relation_type_plugins');
}
/**
* {@inheritdoc}
*/
protected function getDiscovery() {
if (!$this->discovery) {
$directories = [
'core' => $this->root . '/core',
];
$directories += array_map(function (Extension $extension) {
return $this->root . '/' . $extension->getPath();
}, $this->moduleHandler
->getModuleList());
$this->discovery = new YamlDiscovery('link_relation_types', $directories);
}
return $this->discovery;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
LinkRelationTypeManager | Provides a default plugin manager for link relation types. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.