You are here

public function FeaturesCommands::importAll in Features 8.3

Same name and namespace in other branches
  1. 8.4 src/Commands/FeaturesCommands.php \Drupal\features\Commands\FeaturesCommands::importAll()

Import module config from all installed features.

@command features:import:all

@option bundle Use a specific bundle namespace.

@usage drush features-import-all Import module config from all installed features.

@aliases fra,fia,fim-all,features-import-all

File

src/Commands/FeaturesCommands.php, line 311

Class

FeaturesCommands
Drush commands for Features.

Namespace

Drupal\features\Commands

Code

public function importAll($options = self::OPTIONS_IMPORT_ALL) {
  $assigner = $this
    ->featuresOptions($options);
  $currentBundle = $assigner
    ->getBundle();
  $namespace = $currentBundle
    ->isDefault() ? FeaturesBundleInterface::DEFAULT_BUNDLE : $currentBundle
    ->getMachineName();
  $manager = $this->manager;
  $packages = $manager
    ->getPackages();
  $packages = $manager
    ->filterPackages($packages, $namespace);
  $overridden = [];
  foreach ($packages as $package) {
    $overrides = $manager
      ->detectOverrides($package);
    $missing = $manager
      ->detectMissing($package);
    if ((!empty($missing) || !empty($overrides)) && $package
      ->getStatus() == FeaturesManagerInterface::STATUS_INSTALLED) {
      $overridden[] = $package
        ->getMachineName();
    }
  }
  if (!empty($overridden)) {
    $this
      ->import($overridden);
  }
  else {
    $this->logger
      ->info(dt('Current state already matches active config, aborting.'));
  }
}