You are here

function drush_features_import_all in Features 8.3

Same name and namespace in other branches
  1. 8.4 drush/features.drush8.inc \drush_features_import_all()

Drush command callback for features-import-all.

File

drush/features.drush8.inc, line 265
Features module drush integration.

Code

function drush_features_import_all() {
  $assigner = _drush_features_options();
  $current_bundle = $assigner
    ->getBundle();
  $namespace = $current_bundle
    ->isDefault() ? FeaturesBundleInterface::DEFAULT_BUNDLE : $current_bundle
    ->getMachineName();

  /** @var \Drupal\features\FeaturesManagerInterface $manager */
  $manager = \Drupal::service('features.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)) {
    call_user_func_array('drush_features_import', $overridden);
  }
  else {
    drush_log(dt('Current state already matches active config, aborting.'), 'ok');
  }
}