You are here

protected function FeaturesEditForm::importMissing in Features 8.3

Same name and namespace in other branches
  1. 8.4 modules/features_ui/src/Form/FeaturesEditForm.php \Drupal\features_ui\Form\FeaturesEditForm::importMissing()

Imports the configuration missing from the active store.

1 call to FeaturesEditForm::importMissing()
FeaturesEditForm::submitForm in modules/features_ui/src/Form/FeaturesEditForm.php
Form submission handler.

File

modules/features_ui/src/Form/FeaturesEditForm.php, line 1033

Class

FeaturesEditForm
Defines the features settings form.

Namespace

Drupal\features_ui\Form

Code

protected function importMissing() {
  $config = $this->featuresManager
    ->getConfigCollection();
  $missing = $this->featuresManager
    ->reorderMissing($this->missing);
  foreach ($missing as $config_name) {
    if (!isset($config[$config_name])) {
      $item = $this->featuresManager
        ->getConfigType($config_name);
      $type = ConfigurationItem::fromConfigStringToConfigType($item['type']);
      try {
        $this->configRevert
          ->import($type, $item['name_short']);
        $this
          ->messenger()
          ->addStatus($this
          ->t('Imported @name', [
          '@name' => $config_name,
        ]));
      } catch (\Exception $e) {
        $this
          ->messenger()
          ->addError($this
          ->t('Error importing @name : @message', [
          '@name' => $config_name,
          '@message' => $e
            ->getMessage(),
        ]));
      }
    }
  }
}