You are here

public function FeaturesManager::getFeaturesModules in Features 8.3

Same name and namespace in other branches
  1. 8.4 src/FeaturesManager.php \Drupal\features\FeaturesManager::getFeaturesModules()

Returns a list of Features modules regardless of if they are installed.

Parameters

\Drupal\features\FeaturesBundleInterface $bundle: Optional bundle to filter module list. If given, only modules matching the bundle namespace will be returned. If the bundle uses a profile, only modules in the profile will be returned.

bool $installed: List only installed modules.

Return value

Drupal\Core\Extension\Extension[] An array of extension objects.

Overrides FeaturesManagerInterface::getFeaturesModules

3 calls to FeaturesManager::getFeaturesModules()
FeaturesManager::getPackageObject in src/FeaturesManager.php
Initializes and returns a package or profile array.
FeaturesManager::listExistingConfig in src/FeaturesManager.php
Lists names of configuration items provided by existing Features modules.
FeaturesManager::listPackageDirectories in src/FeaturesManager.php
Lists directories in which packages are present.

File

src/FeaturesManager.php, line 501

Class

FeaturesManager
The FeaturesManager provides helper functions for building packages.

Namespace

Drupal\features

Code

public function getFeaturesModules(FeaturesBundleInterface $bundle = NULL, $installed = FALSE) {
  $modules = $this
    ->getAllModules();

  // Filter by bundle.
  $features_manager = $this;
  $modules = array_filter($modules, function ($module) use ($features_manager, $bundle) {
    return $features_manager
      ->isFeatureModule($module, $bundle);
  });

  // Filtered by installed status.
  if ($installed) {
    $features_manager = $this;
    $modules = array_filter($modules, function ($extension) use ($features_manager) {
      return $features_manager
        ->extensionEnabled($extension);
    });
  }
  return $modules;
}