コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function updateExtension($type, $name, array $changelist = array(), $safe_only = TRUE)
 {
     // If no change list was passed, load one.
     if (empty($changelist)) {
         $changelist = $this->configSyncLister->getExtensionChangelist($type, $name, $safe_only);
     }
     // Process create changes.
     if (!empty($changelist['create'])) {
         foreach ($changelist['create'] as $item_name) {
             if (!($entity_type = $this->configManager->getEntityTypeIdByName($name))) {
                 $entity_type = 'system.simple';
             }
             $this->configRevert->import($entity_type, $item_name);
         }
     }
     // Process update changes.
     if (!empty($changelist['update'])) {
         foreach ($changelist['update'] as $item_name) {
             if (!($entity_type = $this->configManager->getEntityTypeIdByName($name))) {
                 $entity_type = 'system.simple';
             }
             $this->configRevert->revert($entity_type, $item_name);
         }
     }
     // Refresh the configuration snapshot.
     $this->configSyncSnapshotter->createExtensionSnapshot($type, $name);
 }
コード例 #2
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('No configuration was selected for import.', 'warning');
     return;
   }
   foreach ($items as $config_name) {
     if (isset($config[$config_name])) {
       $item = $config[$config_name];
       $this->configRevert->revert($item['type'], $item['name_short']);
     }
     else {
       $item = $this->featuresManager->getConfigType($config_name);
       $this->configRevert->import($item['type'], $item['name_short']);
     }
     drupal_set_message(t('Imported !name', array('!name' => $config_name)));
   }
 }
コード例 #3
0
 /**
  * Imports configuration from a module, theme, or profile.
  *
  * Configuration is assumed not to currently exist.
  *
  * @param string $config_type
  *   The type of configuration.
  * @param string $config_name
  *   The name of the config item, without the prefix.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   Redirects to the updates report.
  */
 public function import($config_type, $config_name)
 {
     $this->configRevert->import($config_type, $config_name);
     drupal_set_message($this->t('The configuration was imported.'));
     return $this->redirect('config_update_ui.report');
 }
コード例 #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');
             }
         }
     }
 }