本文整理汇总了PHP中Drupal\Core\Config\ConfigImporter::doSyncStep方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigImporter::doSyncStep方法的具体用法?PHP ConfigImporter::doSyncStep怎么用?PHP ConfigImporter::doSyncStep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\ConfigImporter
的用法示例。
在下文中一共展示了ConfigImporter::doSyncStep方法的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()));
}
}
}
示例2: testCustomStep
/**
* Tests that the isConfigSyncing flag is set correctly during a custom step.
*/
public function testCustomStep()
{
$this->assertFalse(\Drupal::isConfigSyncing(), 'Before an import \\Drupal::isConfigSyncing() returns FALSE');
$context = [];
$this->configImporter->doSyncStep([self::class, 'customStep'], $context);
$this->assertTrue($context['is_syncing'], 'Inside a custom step \\Drupal::isConfigSyncing() returns TRUE');
$this->assertFalse(\Drupal::isConfigSyncing(), 'After an valid custom step \\Drupal::isConfigSyncing() returns FALSE');
}