예제 #1
0
 /**
  * {@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)));
     }
 }
예제 #2
0
 /**
  * Helper function to update dependencies array for a specific config item
  * @param \Drupal\features\ConfigurationItem $config a config item
  * @param array $module_list
  * @return array $dependencies
  */
 protected function getConfigDependency(ConfigurationItem $config, $module_list = array())
 {
     $dependencies = [];
     $type = $config->getType();
     if ($type != FeaturesManagerInterface::SYSTEM_SIMPLE_CONFIG) {
         $provider = $this->entityManager->getDefinition($type)->getProvider();
         // Ensure the provider is an installed module and not, for example, 'core'
         if (isset($module_list[$provider])) {
             $dependencies[] = $provider;
         }
         // For configuration in the InstallStorage::CONFIG_INSTALL_DIRECTORY
         // directory, set any module dependencies of the configuration item
         // as package dependencies.
         // As its name implies, the core-provided
         // InstallStorage::CONFIG_OPTIONAL_DIRECTORY should not create
         // dependencies.
         if ($config->getSubdirectory() === InstallStorage::CONFIG_INSTALL_DIRECTORY && isset($config->getData()['dependencies']['module'])) {
             $dependencies = array_merge($dependencies, $config->getData()['dependencies']['module']);
         }
     }
     return $dependencies;
 }
 /**
  * @covers ::fromConfigStringToConfigType
  */
 public function testFromConfigStringToConfigType()
 {
     $this->assertEquals('system.simple', ConfigurationItem::fromConfigStringToConfigType(FeaturesManagerInterface::SYSTEM_SIMPLE_CONFIG));
     $this->assertEquals('node', ConfigurationItem::fromConfigStringToConfigType('node'));
 }
예제 #4
0
 /**
  * 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');
             }
         }
     }
 }