当前位置: 首页>>代码示例>>PHP>>正文


PHP ConfigImporter::initialize方法代码示例

本文整理汇总了PHP中Drupal\Core\Config\ConfigImporter::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigImporter::initialize方法的具体用法?PHP ConfigImporter::initialize怎么用?PHP ConfigImporter::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Config\ConfigImporter的用法示例。


在下文中一共展示了ConfigImporter::initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: configImport

 private function configImport($io, StorageComparer $storage_comparer)
 {
     $config_importer = new ConfigImporter($storage_comparer, \Drupal::service('event_dispatcher'), \Drupal::service('config.manager'), \Drupal::lock(), \Drupal::service('config.typed'), \Drupal::moduleHandler(), \Drupal::service('module_installer'), \Drupal::service('theme_handler'), \Drupal::service('string_translation'));
     if ($config_importer->alreadyImporting()) {
         $io->success($this->trans('commands.config.import.messages.already-imported'));
     } else {
         try {
             if ($config_importer->validate()) {
                 $sync_steps = $config_importer->initialize();
                 foreach ($sync_steps as $step) {
                     $context = array();
                     do {
                         $config_importer->doSyncStep($step, $context);
                     } while ($context['finished'] < 1);
                 }
             }
         } catch (ConfigImporterException $e) {
             $message = 'The import failed due for the following reasons:' . "\n";
             $message .= implode("\n", $config_importer->getErrors());
             $io->error(sprintf($this->trans('commands.site.import.local.messages.error-writing'), $message));
         } catch (\Exception $e) {
             $io->error(sprintf($this->trans('commands.site.import.local.messages.error-writing'), $e->getMessage()));
         }
     }
 }
开发者ID:jeyram,项目名称:DrupalConsole,代码行数:25,代码来源:ImportSingleCommand.php

示例2: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config_importer = new ConfigImporter($form_state->get('storage_comparer'), $this->eventDispatcher, $this->configManager, $this->lock, $this->typedConfigManager, $this->moduleHandler, $this->themeHandler, $this->getStringTranslation());
     if ($config_importer->alreadyImporting()) {
         drupal_set_message($this->t('Another request may be synchronizing configuration already.'));
     } else {
         try {
             $sync_steps = $config_importer->initialize();
             $batch = array('operations' => array(), 'finished' => array(get_class($this), 'finishBatch'), 'title' => t('Synchronizing configuration'), 'init_message' => t('Starting configuration synchronization.'), 'progress_message' => t('Completed @current step of @total.'), 'error_message' => t('Configuration synchronization has encountered an error.'), 'file' => drupal_get_path('module', 'config') . '/config.admin.inc');
             foreach ($sync_steps as $sync_step) {
                 $batch['operations'][] = array(array(get_class($this), 'processBatch'), array($config_importer, $sync_step));
             }
             batch_set($batch);
         } catch (ConfigImporterException $e) {
             // There are validation errors.
             drupal_set_message($this->t('The configuration synchronization failed validation.'));
             foreach ($config_importer->getErrors() as $message) {
                 drupal_set_message($message, 'error');
             }
         }
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:25,代码来源:ConfigSync.php


注:本文中的Drupal\Core\Config\ConfigImporter::initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。