3 namespace Drupal\lazy_route_provider_install_test;
5 use Drupal\Component\Annotation\PluginID;
6 use Drupal\Core\Cache\CacheBackendInterface;
7 use Drupal\Core\Extension\ModuleHandlerInterface;
8 use Drupal\Core\Plugin\DefaultPluginManager;
9 use Drupal\Core\Routing\UrlGeneratorInterface;
12 class PluginManager extends DefaultPluginManager {
15 * PluginManager constructor.
17 * This plugin manager depends on the URL generator to ensure that this
18 * service is instantiated during module installation when the plugin caches
21 * @param \Traversable $namespaces
22 * An object that implements \Traversable which contains the root paths
23 * keyed by the corresponding namespace to look for plugin implementations.
24 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
26 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
28 * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
31 public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, UrlGeneratorInterface $url_generator) {
32 // Generate a URL during construction to prove that URL generation works. If
33 // the route was missing an exception would be thrown. This also forces the
34 // route provider to be initialized very early during a module install.
35 \Drupal::state()->set(__CLASS__, Url::fromRoute('system.admin')->toString());
36 parent::__construct('Plugin/LazyRouteProviderInstallTest', $namespaces, $module_handler, NULL, PluginID::class);