You are here

public function ComponentDiscovery::getComponents in Decoupled Blocks 8

Find all available front-end components.

Return value

\Drupal\Core\Extension\Extension[] The discovered components.

Overrides ComponentDiscoveryInterface::getComponents

File

src/ComponentDiscovery.php, line 73

Class

ComponentDiscovery
Discovery service for front-end components provided by modules and themes.

Namespace

Drupal\pdb

Code

public function getComponents() {

  // Find components.
  $components = $this
    ->scan('pdb');

  // Set defaults for module info.
  $defaults = [
    'dependencies' => [],
    'description' => '',
    'version' => NULL,
  ];

  // Read info files for each module.
  foreach ($components as $key => $component) {

    // Look for the info file.
    $component->info = $this->infoParser
      ->parse($component
      ->getPathname());

    // Merge in defaults and save.
    $components[$key]->info = $component->info + $defaults;
  }
  $this->moduleHandler
    ->alter('component_info', $components);
  return $components;
}