LinkRelationTypeManager.php in Drupal 8
File
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;
class LinkRelationTypeManager extends DefaultPluginManager {
protected $defaults = [
'class' => LinkRelationType::class,
];
protected $root;
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', [
'link_relation_type',
]);
}
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;
}
}