本文整理匯總了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');
}