getModuleDirectories example

$moduleHandler->getModuleList()->willReturn($modules_to_enable);
    vfsStreamWrapper::register();
    $root = new vfsStreamDirectory('modules');
    vfsStreamWrapper::setRoot($root);
    $url = vfsStream::url('modules');

    foreach ($files as $module => $contents) {
      $path = $url . '/' . $module . '/migrations/state';
      mkdir($path, '0755', TRUE);
      file_put_contents($path . '/' . $module . '.migrate_drupal.yml', $contents);
    }
    $moduleHandler->getModuleDirectories()
      ->willReturn(array_combine(array_keys($files)array_map(function D$module) use ($url) {
        return $url . '/' . $module;
      }array_keys($files))));
    $migrationState = new MigrationState($fieldPluginManager->reveal()$moduleHandler->reveal()$this->createMock(MessengerInterface::class)$this->getStringTranslationStub());

    $all_migrations = [];
    foreach ($migrations as $name => $values) {
      $migration = $this->prophesize(MigrationInterface::class);
      $source = $this->prophesize(MigrateSourceInterface::class);
      $destination = $this->prophesize(MigrateDestinationInterface::class);
      $source->getSourceModule()->willReturn($values['source_module']);
      
$this->controllerResolver = $controller_resolver;
  }

  /** * Gets the YAML discovery. * * @return \Drupal\Core\Discovery\YamlDiscovery * The YAML discovery. */
  protected function getYamlDiscovery() {
    if (!isset($this->yamlDiscovery)) {
      $this->yamlDiscovery = new YamlDiscovery('permissions', $this->moduleHandler->getModuleDirectories());
    }
    return $this->yamlDiscovery;
  }

  /** * {@inheritdoc} */
  public function getPermissions() {
    $all_permissions = $this->buildPermissionsYaml();

    return $this->sortPermissions($all_permissions);
  }
    $definition['parent'] = (string) $definition['parent'];
    $definition['id'] = $plugin_id;
  }

  /** * 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;
  }

  /** * Gets the plugin factory. * * @return \Drupal\Component\Plugin\Factory\FactoryInterface */
->with($this->logicalOr('module_implements', 'hook_info'));
    $module_handler->invokeAllWith('hook', function Dcallable $hook, string $module) {});
  }

  /** * @covers ::getModuleDirectories */
  public function testGetModuleDirectories() {
    $module_handler = $this->getModuleHandler();
    $module_handler->setModuleList([]);
    $module_handler->addModule('node', 'core/modules/node');
    $this->assertEquals(['node' => $this->root . '/core/modules/node']$module_handler->getModuleDirectories());
  }

}
$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.
\Drupal::setContainer($container);

    $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);

    $this->moduleHandler->moduleExists('module_a')->willReturn(TRUE);
    $this->moduleHandler->moduleExists('theme_a')->willReturn(FALSE);
    $this->moduleHandler->moduleExists('core')->willReturn(FALSE);
    $this->moduleHandler->moduleExists('invalid_provider')->willReturn(FALSE);

    $module_a = new Extension('vfs://root', 'module', 'modules/module_a/module_a.layouts.yml');
    $this->moduleHandler->getModule('module_a')->willReturn($module_a);
    $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->moduleHandler = $module_handler;
    $this->account = $account;
    $this->alterInfo('menu_local_actions');
    $this->setCacheBackend($cache_backend, 'local_action_plugins:' . $language_manager->getCurrentLanguage()->getId()['local_action']);
  }

  /** * {@inheritdoc} */
  protected function getDiscovery() {
    if (!isset($this->discovery)) {
      $yaml_discovery = new YamlDiscovery('links.action', $this->moduleHandler->getModuleDirectories());
      $yaml_discovery->addTranslatableProperty('title', 'title_context');
      $this->discovery = new ContainerDerivativeDiscoveryDecorator($yaml_discovery);
    }
    return $this->discovery;
  }

  /** * {@inheritdoc} */
  public function getTitle(LocalActionInterface $local_action) {
    $controller = [$local_action, 'getTitle'];
    

  }

  /** * 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. */
// Use the 'config:core.extension' cache tag so the plugin cache is     // invalidated on theme install and uninstall.     $this->setCacheBackend($cache_backend, 'help_topics', ['config:core.extension']);
    $this->root = (string) $root;
  }

  /** * {@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);
      

  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';
    

  protected function getMigrationStates() {
    // Always instantiate a new YamlDiscovery object so that we always search on     // the up-to-date list of modules.     $discovery = new YamlDiscovery('migrate_drupal', array_map(function D$value) {
      return $value . '/migrations/state';
    }$this->moduleHandler->getModuleDirectories()));
    return $discovery->findAll();
  }

  /** * Determines migration state for each source module enabled on the source. * * If there are no migrations for a module and no declared state the state is * set to NOT_FINISHED. When a module does not need any migrations, such as * Overlay, a state of finished is declared in system.migrate_drupal.yml. * * If there are migrations for a module the following happens. If the * destination module is 'core' the state is set to FINISHED. If there are * any occurrences of 'not_finished' in the *.migrate_drupal.yml information * for this source module then the state is set to NOT_FINISHED. And finally, * if there is an occurrence of 'finished' the state is set to FINISHED. * * @param string $version * The legacy drupal version. * @param array $source_system_data * The data from the source site system table. * @param array $migrations * An array of migrations. * * @return array * An associative array of data with keys of state, source modules and a * value which is a comma separated list of destination modules. * Example. * * @code * [ * 'finished' => [ * 'menu' => [ * 'menu_link_content','menu_ui','system' * ] * ], * ] * @endcode */
$this->alterInfo('ckeditor5_plugin_info');
    $this->setCacheBackend($cache_backend, 'ckeditor5_plugins');
  }

  /** * {@inheritdoc} */
  protected function getDiscovery() {
    if (!$this->discovery) {
      $discovery = new AnnotatedClassDiscovery($this->subdir, $this->namespaces, $this->pluginDefinitionAnnotationName, $this->additionalAnnotationNamespaces);
      $discovery = new YamlDiscoveryDecorator($discovery, 'ckeditor5', $this->moduleHandler->getModuleDirectories());
      // Note: adding translatable properties here is impossible because it only       // supports top-level properties.       // @see \Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition::label()       $discovery = new AnnotationBridgeDecorator($discovery$this->pluginDefinitionAnnotationName);
      $discovery = new ContainerDerivativeDiscoveryDecorator($discovery);
      $this->discovery = $discovery;
    }
    return $this->discovery;
  }

  /** * {@inheritdoc} */
$this->moduleHandler = $module_handler;
    $this->requestStack = $request_stack;
    $this->alterInfo('contextual_links_plugins');
    $this->setCacheBackend($cache_backend, 'contextual_links_plugins:' . $language_manager->getCurrentLanguage()->getId()['contextual_links_plugins']);
  }

  /** * {@inheritdoc} */
  protected function getDiscovery() {
    if (!isset($this->discovery)) {
      $yaml_discovery = new YamlDiscovery('links.contextual', $this->moduleHandler->getModuleDirectories());
      $yaml_discovery->addTranslatableProperty('title', 'title_context');
      $this->discovery = new ContainerDerivativeDiscoveryDecorator($yaml_discovery);
    }
    return $this->discovery;
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    parent::processDefinition($definition$plugin_id);

    


  /** * 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();
  }

}

      }
    }

    // Get the declared migration state information from .migrate_drupal.yml     // and build an array of source modules and there migration state. The     // destination is not used yet but can be later for validating the     // source/destination pairs with the actual source/destination pairs in the     // migrate plugins.     $system_info = (new YamlDiscovery('migrate_drupal', array_map(function D$value) {
      return $value . '/migrations/state/';
    }, \Drupal::moduleHandler()->getModuleDirectories())))->findAll();

    $declared = [
      MigrationState::FINISHED => [],
      MigrationState::NOT_FINISHED => [],
    ];
    foreach ($system_info as $module => $info) {
      foreach (array_keys($declared) as $state) {
        if (isset($info[$state][$version])) {
          foreach ($info[$state][$version] as $source => $destination) {
            // Do not add the source module i18nstrings or i18_string. The             // 18n migrations can have up to three source modules but only one
Home | Imprint | This part of the site doesn't use cookies.