Commit 1dbc4128 authored by catch's avatar catch
Browse files

Issue #3318581 by andypost, alexpott: FIx...

Issue #3318581 by andypost, alexpott: FIx \Drupal\Core\Config\ConfigImporter::doSyncStep() to accept callable

(cherry picked from commit fcf0932d)
parent 3af57f41
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -507,13 +507,13 @@ public function import() {
   *   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');
+1 −1
Original line number Diff line number Diff line
@@ -822,7 +822,7 @@ public function testInvalidStep() {
  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');
  }