Skip to content

Commit

Permalink
[config:*] Add configuration to stop site uuid config import/export e…
Browse files Browse the repository at this point in the history
…rror. (#3806)
  • Loading branch information
jmolivas authored Feb 23, 2018
1 parent 85a6948 commit e66605e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 31 deletions.
7 changes: 4 additions & 3 deletions src/Bootstrap/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,14 @@ public function boot()
$io->writeln('➤ Registering dynamic services');
}

$configuration = $this->configurationManager->getConfiguration();

$drupalKernel->addServiceModifier(
new DrupalServiceModifier(
$this->drupalFinder->getComposerRoot(),
'drupal.command',
'drupal.generator'
'drupal.generator',
$configuration
)
);

Expand Down Expand Up @@ -193,8 +196,6 @@ public function boot()
$this->configurationManager
);

$configuration = $this->configurationManager->getConfiguration();

$container->get('console.translator_manager')
->loadCoreLanguage(
$configuration->get('application.language'),
Expand Down
24 changes: 24 additions & 0 deletions src/Bootstrap/DrupalCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Drupal\Console\Bootstrap;

use Dflydev\DotAccessConfiguration\ConfigurationInterface;
use Drupal\Console\Override\ConfigSubscriber;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Drupal\Console\Utils\TranslatorManager;
Expand All @@ -12,6 +14,18 @@
*/
class DrupalCompilerPass implements CompilerPassInterface
{
protected $configuration;

/**
* DrupalCompilerPass constructor.
*
* @param ConfigurationInterface $configuration
*/
public function __construct(ConfigurationInterface $configuration)
{
$this->configuration = $configuration;
}

/**
* @inheritdoc
*/
Expand All @@ -28,6 +42,16 @@ public function process(ContainerBuilder $container)
->getDefinition('console.translator_manager')
->setClass(TranslatorManager::class);

$skipValidateSiteUuid = $this->configuration
->get('application.overrides.config.skip-validate-site-uuid');

if ($skipValidateSiteUuid) {
// override system.config_subscriber
$container
->getDefinition('system.config_subscriber')
->setClass(ConfigSubscriber::class);
}

// Set console.invalid_commands service
$container
->get('console.key_value_storage')
Expand Down
24 changes: 11 additions & 13 deletions src/Bootstrap/DrupalServiceModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\Core\DependencyInjection\ServiceModifierInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Dflydev\DotAccessConfiguration\ConfigurationInterface;

/**
* Class DrupalServiceModifier
Expand All @@ -27,21 +28,26 @@ class DrupalServiceModifier implements ServiceModifierInterface
*/
protected $generatorTag;

protected $configuration;

/**
* DrupalServiceModifier constructor.
*
* @param string $root
* @param string $serviceTag
* @param string $generatorTag
* @param string $root
* @param string $serviceTag
* @param string $generatorTag
* @param ConfigurationInterface $configuration
*/
public function __construct(
$root = null,
$serviceTag,
$generatorTag
$generatorTag,
$configuration
) {
$this->root = $root;
$this->commandTag = $serviceTag;
$this->generatorTag = $generatorTag;
$this->configuration = $configuration;
}

/**
Expand All @@ -50,15 +56,7 @@ public function __construct(
public function alter(ContainerBuilder $container)
{
$container->addCompilerPass(
new DrupalCompilerPass()
new DrupalCompilerPass($this->configuration)
);

// $container->addCompilerPass(
// new FindCommandsCompilerPass($this->commandTag)
// );
//
// $container->addCompilerPass(
// new FindGeneratorsCompilerPass($this->generatorTag)
// );
}
}
26 changes: 26 additions & 0 deletions src/Override/ConfigSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Drupal\Console\Override;

use Drupal\system\SystemConfigSubscriber;
use Drupal\Core\Config\ConfigImporterEvent;
use Drupal\Core\Config\ConfigEvents;

/**
* Class ConfigSubscriber
*
* @package Drupal\Console\Override
*/
class ConfigSubscriber extends SystemConfigSubscriber
{

/**
* @param \Drupal\Core\Config\ConfigImporterEvent $event
* @return bool
*/
public function onConfigImporterValidateSiteUUID(ConfigImporterEvent $event)
{
$event->stopPropagation();
return true;
}
}
15 changes: 0 additions & 15 deletions src/Override/StorageComparer.php

This file was deleted.

0 comments on commit e66605e

Please sign in to comment.