cac59a7324ff42f92808736ef4ce41aa7cdc8763
[yaffs-website] / web / core / modules / system / tests / modules / lazy_route_provider_install_test / src / PluginManager.php
1 <?php
2
3 namespace Drupal\lazy_route_provider_install_test;
4
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;
10 use Drupal\Core\Url;
11
12 class PluginManager extends DefaultPluginManager {
13
14   /**
15    * PluginManager constructor.
16    *
17    * This plugin manager depends on the URL generator to ensure that this
18    * service is instantiated during module installation when the plugin caches
19    * are cleared.
20    *
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
25    *   A cache backend.
26    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
27    *   The module handler.
28    * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
29    *   The URL generator.
30    */
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);
37   }
38
39 }