From 6df07b19b9835129d2037af4de502b14dd15ae5a Mon Sep 17 00:00:00 2001 From: Adam Kadlec Date: Fri, 15 Nov 2019 13:54:48 +0100 Subject: [PATCH 1/2] - Better nette 3 support --- .../DI/DoctrineConsistenceExtension.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/IPub/DoctrineConsistence/DI/DoctrineConsistenceExtension.php b/src/IPub/DoctrineConsistence/DI/DoctrineConsistenceExtension.php index c210cff..dce2ba5 100644 --- a/src/IPub/DoctrineConsistence/DI/DoctrineConsistenceExtension.php +++ b/src/IPub/DoctrineConsistence/DI/DoctrineConsistenceExtension.php @@ -56,12 +56,12 @@ public function loadConfiguration() : void { // Get container builder $builder = $this->getContainerBuilder(); - - // Merge extension default config - $this->setConfig(DI\Config\Helpers::merge($this->config, DI\Helpers::expand($this->defaults, $builder->parameters))); - - // Get extension configuration - $configuration = $this->getConfig(); + /** @var array $configuration */ + if (method_exists($this, 'validateConfig')) { + $configuration = $this->validateConfig($this->defaults); + } else { + $configuration = $this->getConfig($this->defaults); + } if ($configuration['subscriber']['tag']) { $builder->addDefinition($this->prefix('subscriber')) @@ -79,12 +79,12 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class) : void // Get container builder $builder = $this->getContainerBuilder(); - - // Merge extension default config - $this->setConfig(DI\Config\Helpers::merge($this->config, DI\Helpers::expand($this->defaults, $builder->parameters))); - - // Get extension configuration - $configuration = $this->getConfig(); + /** @var array $configuration */ + if (method_exists($this, 'validateConfig')) { + $configuration = $this->validateConfig($this->defaults); + } else { + $configuration = $this->getConfig($this->defaults); + } /** @var Nette\PhpGenerator\Method $initialize */ $initialize = $class->getMethods()['initialize']; From b19a0e26c3bffe69783cf90407578324cdd856c6 Mon Sep 17 00:00:00 2001 From: Adam Kadlec Date: Fri, 15 Nov 2019 14:00:48 +0100 Subject: [PATCH 2/2] - Unused code --- .../DoctrineConsistence/DI/DoctrineConsistenceExtension.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/IPub/DoctrineConsistence/DI/DoctrineConsistenceExtension.php b/src/IPub/DoctrineConsistence/DI/DoctrineConsistenceExtension.php index dce2ba5..edeec3d 100644 --- a/src/IPub/DoctrineConsistence/DI/DoctrineConsistenceExtension.php +++ b/src/IPub/DoctrineConsistence/DI/DoctrineConsistenceExtension.php @@ -77,8 +77,6 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class) : void { parent::afterCompile($class); - // Get container builder - $builder = $this->getContainerBuilder(); /** @var array $configuration */ if (method_exists($this, 'validateConfig')) { $configuration = $this->validateConfig($this->defaults);