/** * @covers ::fromConfigStringToConfigType */ public function testFromConfigStringToConfigType() { $this->assertEquals('system.simple', ConfigurationItem::fromConfigStringToConfigType(FeaturesManagerInterface::SYSTEM_SIMPLE_CONFIG)); $this->assertEquals('node', ConfigurationItem::fromConfigStringToConfigType('node')); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->assigner->assignConfigPackages(); $config = $this->featuresManager->getConfigCollection(); $items = array_filter($form_state->getValue('diff')); if (empty($items)) { drupal_set_message($this->t('No configuration was selected for import.'), 'warning'); return; } foreach ($items as $config_name) { if (isset($config[$config_name])) { $item = $config[$config_name]; $type = ConfigurationItem::fromConfigStringToConfigType($item->getType()); $this->configRevert->revert($type, $item->getShortName()); } else { $item = $this->featuresManager->getConfigType($config_name); $type = ConfigurationItem::fromConfigStringToConfigType($item['type']); $this->configRevert->import($type, $item['name_short']); } drupal_set_message(t('Imported @name', array('@name' => $config_name))); } }
/** * Imports the configuration missing from the active store */ 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']); drupal_set_message($this->t('Imported @name', array('@name' => $config_name))); } catch (\Exception $e) { drupal_set_message($this->t('Error importing @name : @message', array('@name' => $config_name, '@message' => $e->getMessage())), 'error'); } } } }