Issue #3318581 by andypost, alexpott: FIx \Drupal\Core\Config\ConfigImporter::doSyncStep() to accept callable
parent
cf3ae0f90d
commit
fcf0932d6a
|
@ -507,13 +507,13 @@ class ConfigImporter {
|
|||
* Exception thrown if the $sync_step can not be called.
|
||||
*/
|
||||
public function doSyncStep($sync_step, &$context) {
|
||||
if (!is_array($sync_step) && method_exists($this, $sync_step)) {
|
||||
if (is_string($sync_step) && method_exists($this, $sync_step)) {
|
||||
\Drupal::service('config.installer')->setSyncing(TRUE);
|
||||
$this->$sync_step($context);
|
||||
}
|
||||
elseif (is_callable($sync_step)) {
|
||||
\Drupal::service('config.installer')->setSyncing(TRUE);
|
||||
call_user_func_array($sync_step, [&$context, $this]);
|
||||
$sync_step($context, $this);
|
||||
}
|
||||
else {
|
||||
throw new \InvalidArgumentException('Invalid configuration synchronization step');
|
||||
|
|
|
@ -822,7 +822,7 @@ class ConfigImporterTest extends KernelTestBase {
|
|||
public function testCustomStep() {
|
||||
$this->assertFalse(\Drupal::isConfigSyncing(), 'Before an import \Drupal::isConfigSyncing() returns FALSE');
|
||||
$context = [];
|
||||
$this->configImporter()->doSyncStep([self::class, 'customStep'], $context);
|
||||
$this->configImporter()->doSyncStep(self::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');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue