getThemeDirectories example


  public function __construct($root_path, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
    parent::__construct([]$root_path);
    // Add help_topics directories for modules and themes in the 'help_topic'     // namespace, plus core.     $this->addExtension($root_path . '/core');
    array_map([$this, 'addExtension']$module_handler->getModuleDirectories());
    array_map([$this, 'addExtension']$theme_handler->getThemeDirectories());
  }

  /** * Adds an extensions help_topics directory to the Twig loader. * * @param $path * The path to the extension. */
  protected function addExtension($path) {
    $path .= DIRECTORY_SEPARATOR . 'help_topics';
    if (is_dir($path)) {
      


  /** * Get the list of directories to scan. * * @return string[] * The directories. */
  private function getScanDirectories(): array {
    $extension_directories = [
      ...$this->moduleHandler->getModuleDirectories(),
      ...$this->themeHandler->getThemeDirectories(),
    ];
    return array_map(
      static fn(string $path) => rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'components',
      $extension_directories
    );
  }

  /** * Changes the library paths, so they can be used by the library system. * * We need this so we can let users apply overrides to JS and CSS files with * paths relative to the component. * * @param array $overrides * The library overrides as provided by the component author. * @param string $component_directory * The directory for the component. * * @return array * The overrides with the fixed paths. */


  /** * {@inheritdoc} */
  protected function getDiscovery() {
    if (!isset($this->discovery)) {
      $module_directories = $this->moduleHandler->getModuleDirectories();
      $all_directories = array_merge(
        ['core' => $this->root . '/core'],
        $module_directories,
        $this->themeHandler->getThemeDirectories()
      );

      // Search for Twig help topics in subdirectory help_topics, under       // modules/profiles, themes, and the core directory.       $all_directories = array_map(function D$dir) {
        return [$dir . '/help_topics'];
      }$all_directories);
      $discovery = new HelpTopicDiscovery($all_directories);

      // Also allow modules/profiles to extend help topic discovery to their       // own plugins and derivers, in mymodule.help_topics.yml files.

  protected function providerExists($provider) {
    return $this->moduleHandler->moduleExists($provider) || $this->themeHandler->themeExists($provider);
  }

  /** * {@inheritdoc} */
  protected function getDiscovery() {
    if (!$this->discovery) {
      $discovery = new AnnotatedClassDiscovery($this->subdir, $this->namespaces, $this->pluginDefinitionAnnotationName, $this->additionalAnnotationNamespaces);
      $discovery = new YamlDiscoveryDecorator($discovery, 'layouts', $this->moduleHandler->getModuleDirectories() + $this->themeHandler->getThemeDirectories());
      $discovery
        ->addTranslatableProperty('label')
        ->addTranslatableProperty('description')
        ->addTranslatableProperty('category');
      $discovery = new AnnotationBridgeDecorator($discovery$this->pluginDefinitionAnnotationName);
      $discovery = new ContainerDerivativeDiscoveryDecorator($discovery);
      $this->discovery = $discovery;
    }
    return $this->discovery;
  }

  
$this->themeHandler = $theme_handler;
    $this->setStringTranslation($string_translation);
    $this->alterInfo('breakpoints');
    $this->setCacheBackend($cache_backend, 'breakpoints', ['breakpoints']);
  }

  /** * {@inheritdoc} */
  protected function getDiscovery() {
    if (!isset($this->discovery)) {
      $this->discovery = new YamlDiscovery('breakpoints', $this->moduleHandler->getModuleDirectories() + $this->themeHandler->getThemeDirectories());
      $this->discovery = new ContainerDerivativeDiscoveryDecorator($this->discovery);
    }
    return $this->discovery;
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    parent::processDefinition($definition$plugin_id);
    // Allow custom groups and therefore more than one group per extension.
$this->moduleHandler->getModuleDirectories()->willReturn(['module_a' => vfsStream::url('root/modules/module_a')]);
    $this->moduleHandler->alter('layout', Argument::type('array'))->shouldBeCalled();

    $this->themeHandler = $this->prophesize(ThemeHandlerInterface::class);

    $this->themeHandler->themeExists('theme_a')->willReturn(TRUE);
    $this->themeHandler->themeExists('core')->willReturn(FALSE);
    $this->themeHandler->themeExists('invalid_provider')->willReturn(FALSE);

    $theme_a = new Extension('vfs://root', 'theme', 'themes/theme_a/theme_a.layouts.yml');
    $this->themeHandler->getTheme('theme_a')->willReturn($theme_a);
    $this->themeHandler->getThemeDirectories()->willReturn(['theme_a' => vfsStream::url('root/themes/theme_a')]);

    $this->cacheBackend = $this->prophesize(CacheBackendInterface::class);

    $namespaces = new \ArrayObject(['Drupal\Core' => vfsStream::url('root/core/lib/Drupal/Core')]);
    $this->layoutPluginManager = new LayoutPluginManager($namespaces$this->cacheBackend->reveal()$this->moduleHandler->reveal()$this->themeHandler->reveal());
  }

  /** * @covers ::getDefinitions * @covers ::providerExists */
  
Home | Imprint | This part of the site doesn't use cookies.