本文整理汇总了PHP中Drupal\Core\Extension\ModuleHandlerInterface::getModuleDirectories方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleHandlerInterface::getModuleDirectories方法的具体用法?PHP ModuleHandlerInterface::getModuleDirectories怎么用?PHP ModuleHandlerInterface::getModuleDirectories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Extension\ModuleHandlerInterface
的用法示例。
在下文中一共展示了ModuleHandlerInterface::getModuleDirectories方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getYamlDiscovery
/**
* 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;
}
示例2: getDiscovery
/**
* {@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;
}
示例3: getRouteDefinitions
/**
* 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();
}
示例4: getAllTemplates
/**
* 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;
}
示例5: getRouteDefinitions
/**
* 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();
}
示例6: __construct
/**
* {@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;
}
示例7: getDiscovery
/**
* 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;
}
示例8: getDiscovery
/**
* 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;
}
示例9: getDiscovery
/**
* {@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;
}
示例10: __construct
/**
* 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;
}
示例11: __construct
/**
* 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'));
}
示例12: getPluginTypes
/**
* {@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;
}
示例13: getDiscovery
/**
* 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());
}
示例14: __construct
/**
* 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'));
}
示例15: __construct
/**
* 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'));
}