You are here

public function ConfigFeaturesImporterService::importFeatures in Config Importer and Tools 8

Same name and namespace in other branches
  1. 8.2 src/ConfigFeaturesImporterService.php \Drupal\config_import\ConfigFeaturesImporterService::importFeatures()

Import features.

Parameters

string[] $features: Feature names.

Overrides ConfigFeaturesImporterServiceInterface::importFeatures

File

src/ConfigFeaturesImporterService.php, line 85

Class

ConfigFeaturesImporterService
Class ConfigFeaturesImporterService.

Namespace

Drupal\config_import

Code

public function importFeatures(array $features) {
  $packages = $this->featuresManager
    ->getPackages();
  foreach ($features as $feature) {
    if (empty($packages[$feature])) {
      $error = 'Feature "@feature" does not exist.';
    }
    elseif ($packages[$feature]
      ->getStatus() === FeaturesManagerInterface::STATUS_NO_EXPORT) {
      $error = 'Feature "@feature" marked as non exportable.';
    }
    if (isset($error)) {
      $this->loggerChannel
        ->error($error, [
        '@feature' => $feature,
      ]);
    }
    else {
      $this
        ->import($packages[$feature]);
    }
  }
}