/** * Gets the YAML discovery. * * @return \Drupal\Component\Discovery\YamlDiscovery * The YAML discovery. */ protected function getYamlDiscovery() { if (!isset($this->yamlDiscovery)) { $this->yamlDiscovery = new YamlDiscovery('permissions', $this->moduleHandler->getModuleDirectories()); } return $this->yamlDiscovery; }
/** * {@inheritdoc} */ protected function getDiscovery() { if (!isset($this->discovery)) { $directories = array_map(function ($directory) { return [$directory . '/migration_templates', $directory . '/migrations']; }, $this->moduleHandler->getModuleDirectories()); $yaml_discovery = new YamlDirectoryDiscovery($directories, 'migrate'); $this->discovery = new ContainerDerivativeDiscoveryDecorator($yaml_discovery); } return $this->discovery; }
/** * Retrieves all defined routes from .routing.yml files. * * @return array * The defined routes, keyed by provider. */ protected function getRouteDefinitions() { if (!isset($this->yamlDiscovery)) { $this->yamlDiscovery = new YamlDiscovery('routing', $this->moduleHandler->getModuleDirectories()); } return $this->yamlDiscovery->findAll(); }
/** * Retrieves all migration templates belonging to enabled extensions. * * @return array * Array of parsed templates, keyed by the fully-qualified id. */ public function getAllTemplates() { $templates = []; foreach ($this->moduleHandler->getModuleDirectories() as $directory) { $full_directory = $directory . '/' . $this->directory; if (file_exists($full_directory)) { $files = scandir($full_directory); foreach ($files as $file) { if ($file[0] !== '.' && fnmatch('*.yml', $file)) { $templates[basename($file, '.yml')] = Yaml::decode(file_get_contents("{$full_directory}/{$file}")); } } } } return $templates; }
/** * Retrieves all defined routes from .routing.yml files. * * @return array * The defined routes, keyed by provider. */ protected function getRouteDefinitions() { // Always instantiate a new YamlDiscovery object so that we always search on // the up-to-date list of modules. $discovery = new YamlDiscovery('routing', $this->moduleHandler->getModuleDirectories()); return $discovery->findAll(); }
/** * {@inheritdoc} */ public function __construct(ModuleHandlerInterface $module_handler) { $this->alterInfo('rules_event'); $this->discovery = new ContainerDerivativeDiscoveryDecorator(new YamlDiscovery('rules.events', $module_handler->getModuleDirectories())); $this->factory = new ContainerFactory($this, RulesEventInterface::class); $this->moduleHandler = $module_handler; }
/** * Instantiates if necessary and returns a YamlDiscovery instance. * * Since the discovery is very rarely used - only when the rebuild() method * is called - it's instantiated only when actually needed instead of in the * constructor. * * @return \Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator * A plugin discovery instance. */ protected function getDiscovery() { if (empty($this->discovery)) { $yaml = new YamlDiscovery('links.menu', $this->moduleHandler->getModuleDirectories()); $this->discovery = new ContainerDerivativeDiscoveryDecorator($yaml); } return $this->discovery; }
/** * Gets the plugin discovery. * * @return \Drupal\Component\Plugin\Discovery\DiscoveryInterface */ protected function getDiscovery() { if (!isset($this->discovery)) { $yaml_discovery = new YamlDiscovery('links.menu', $this->moduleHandler->getModuleDirectories()); $yaml_discovery->addTranslatableProperty('title', 'title_context'); $yaml_discovery->addTranslatableProperty('description', 'description_context'); $this->discovery = new ContainerDerivativeDiscoveryDecorator($yaml_discovery); } return $this->discovery; }
/** * {@inheritdoc} */ protected function getDiscovery() { if (!isset($this->discovery)) { $directories = array_map(function ($directory) { return [$directory . '/migration_templates', $directory . '/migrations']; }, $this->moduleHandler->getModuleDirectories()); $yaml_discovery = new YamlDirectoryDiscovery($directories, 'migrate'); // This gets rid of migrations which try to use a non-existent source // plugin. The common case for this is if the source plugin has, or // specifies, a non-existent provider. $only_with_source_discovery = new NoSourcePluginDecorator($yaml_discovery); // This gets rid of migrations with explicit providers set if one of the // providers do not exist before we try to use a potentially non-existing // deriver. This is a rare case. $filtered_discovery = new ProviderFilterDecorator($only_with_source_discovery, [$this->moduleHandler, 'moduleExists']); $this->discovery = new ContainerDerivativeDiscoveryDecorator($filtered_discovery); } return $this->discovery; }
/** * Constructs a new instance. * * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * Cache backend instance to use. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler to invoke the alter hook with. * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver * The class_resolver. * @var \Drupal\Core\StringTranslation\TranslationInterface * The string translator. */ public function __construct(CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ClassResolverInterface $class_resolver, TranslationInterface $string_translation) { $this->alterInfo('payment_status'); $this->setCacheBackend($cache_backend, 'payment_status', ['payment_status']); $this->classResolver = $class_resolver; $this->discovery = new YamlDiscovery('payment.status', $module_handler->getModuleDirectories()); $this->discovery = new ContainerDerivativeDiscoveryDecorator($this->discovery); $this->factory = new ContainerFactory($this, PaymentStatusInterface::class); $this->moduleHandler = $module_handler; $this->stringTranslation = $string_translation; }
/** * Constructs a new ContextualLinkManager instance. * * @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver * The controller resolver. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * The cache backend. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. * @param \Drupal\Core\Access\AccessManagerInterface $access_manager * The access manager. * @param \Drupal\Core\Session\AccountInterface $account * The current user. * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * The request stack. */ public function __construct(ControllerResolverInterface $controller_resolver, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, AccessManagerInterface $access_manager, AccountInterface $account, RequestStack $request_stack) { $this->discovery = new YamlDiscovery('links.contextual', $module_handler->getModuleDirectories()); $this->discovery = new ContainerDerivativeDiscoveryDecorator($this->discovery); $this->factory = new ContainerFactory($this, '\\Drupal\\Core\\Menu\\ContextualLinkInterface'); $this->controllerResolver = $controller_resolver; $this->accessManager = $access_manager; $this->account = $account; $this->moduleHandler = $module_handler; $this->requestStack = $request_stack; $this->alterInfo('contextual_links_plugins'); $this->setCacheBackend($cache_backend, 'contextual_links_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('contextual_links_plugins')); }
/** * {@inheritdoc} */ public function getPluginTypes() { if (is_null($this->pluginTypes)) { $this->pluginTypes = []; // Get the plugin type definitions. $plugin_types_data_discovery = new YamlDiscovery('plugin_type', $this->moduleHandler->getModuleDirectories()); $plugin_type_definitions_by_module = $plugin_types_data_discovery->findAll(); // For every definition, set defaults and instantiate an object. foreach ($plugin_type_definitions_by_module as $module => $plugin_type_definitions) { $plugin_type_definition_defaults = ['provider' => $module]; foreach ($plugin_type_definitions as $plugin_type_id => $plugin_type_definition) { $plugin_type_definition += $plugin_type_definition_defaults; if ($plugin_type_definition['provider'] == 'core' || $this->moduleHandler->moduleExists($plugin_type_definition['provider'])) { $plugin_type_definition['id'] = $plugin_type_id; /** @var \Drupal\plugin\PluginType\PluginTypeInterface $class */ $class = isset($plugin_type_definition['class']) ? $plugin_type_definition['class'] : PluginType::class; $plugin_type = $class::createFromDefinition($this->container, $plugin_type_definition); $this->pluginTypes[$plugin_type_id] = $plugin_type; } } } } return $this->pluginTypes; }
/** * Creates a YAML discovery for menu links. * * @return \Drupal\Component\Discovery\YamlDiscovery * An YAML discovery instance. */ protected function getDiscovery() { return new YamlDiscovery('links.menu', $this->moduleHandler->getModuleDirectories()); }
/** * Constructs a new BreakpointManager instance. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler * The theme handler. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * The cache backend. * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * The string translation service. */ public function __construct(ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, CacheBackendInterface $cache_backend, TranslationInterface $string_translation) { $this->discovery = new YamlDiscovery('breakpoints', $module_handler->getModuleDirectories() + $theme_handler->getThemeDirectories()); $this->discovery = new ContainerDerivativeDiscoveryDecorator($this->discovery); $this->factory = new ContainerFactory($this); $this->moduleHandler = $module_handler; $this->themeHandler = $theme_handler; $this->setStringTranslation($string_translation); $this->alterInfo('breakpoints'); $this->setCacheBackend($cache_backend, 'breakpoints', array('breakpoints')); }
/** * Constructs a LocalActionManager object. * * @param \Symfony\Component\HttpKernel\Controller\ControllerResolverInterface $controller_resolver * An object to use in introspecting route methods. * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * The request stack. * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider * The route provider. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * Cache backend instance to use. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. * @param \Drupal\Core\Access\AccessManagerInterface $access_manager * The access manager. * @param \Drupal\Core\Session\AccountInterface $account * The current user. */ public function __construct(ControllerResolverInterface $controller_resolver, RequestStack $request_stack, RouteProviderInterface $route_provider, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, AccessManagerInterface $access_manager, AccountInterface $account) { // Skip calling the parent constructor, since that assumes annotation-based // discovery. $this->discovery = new YamlDiscovery('links.action', $module_handler->getModuleDirectories()); $this->discovery = new ContainerDerivativeDiscoveryDecorator($this->discovery); $this->factory = new ContainerFactory($this, 'Drupal\\Core\\Menu\\LocalActionInterface'); $this->controllerResolver = $controller_resolver; $this->requestStack = $request_stack; $this->routeProvider = $route_provider; $this->accessManager = $access_manager; $this->moduleHandler = $module_handler; $this->account = $account; $this->alterInfo('menu_local_actions'); $this->setCacheBackend($cache_backend, 'local_action_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('local_action')); }
/** * Constructs a \Drupal\Core\Menu\LocalTaskManager object. * * @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver * An object to use in introspecting route methods. * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * The request object to use for building titles and paths for plugin instances. * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * The current route match. * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider * The route provider to load routes by name. * @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder * The route builder. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. * @param \Drupal\Core\Access\AccessManagerInterface $access_manager * The access manager. * @param \Drupal\Core\Session\AccountInterface $account * The current user. */ public function __construct(ControllerResolverInterface $controller_resolver, RequestStack $request_stack, RouteMatchInterface $route_match, RouteProviderInterface $route_provider, RouteBuilderInterface $route_builder, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, LanguageManagerInterface $language_manager, AccessManagerInterface $access_manager, AccountInterface $account) { $this->discovery = new YamlDiscovery('links.task', $module_handler->getModuleDirectories()); $this->discovery = new ContainerDerivativeDiscoveryDecorator($this->discovery); $this->factory = new ContainerFactory($this, '\\Drupal\\Core\\Menu\\LocalTaskInterface'); $this->controllerResolver = $controller_resolver; $this->requestStack = $request_stack; $this->routeMatch = $route_match; $this->routeProvider = $route_provider; $this->routeBuilder = $route_builder; $this->accessManager = $access_manager; $this->account = $account; $this->moduleHandler = $module_handler; $this->alterInfo('local_tasks'); $this->setCacheBackend($cache, 'local_task_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('local_task')); }