-
Notifications
You must be signed in to change notification settings - Fork 974
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEXT-36143 - feat: resolve extension parameters in compiler passes
fixes #3684
- Loading branch information
1 parent
8688475
commit dfd0990
Showing
3 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
changelog/_unreleased/2024-04-23-resolve-parameters-in-compiler-passes.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: Resolve extension parameters in Shopware compiler passes | ||
issue: NEXT-36143 | ||
flag: | ||
author: Philip Standt | ||
author_email: philip@maphi.net | ||
author_github: @Ocarthon | ||
--- | ||
# Core | ||
* Changed `\Shopware\Core\Framework\DependencyInjection\CompilerPass\CompilerPassConfigTrait` to resolve extension parameters before processing the values. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...tegration/Core/Framework/DependencyInjection/CompilerPass/CompilerPassConfigTraitTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Shopware\Tests\Integration\Core\Framework\DependencyInjection\CompilerPass; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\TestCase; | ||
use Shopware\Core\Framework\DependencyInjection\CompilerPass\CompilerPassConfigTrait; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; | ||
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
#[CoversClass(CompilerPassConfigTraitTest::class)] | ||
class CompilerPassConfigTraitTest extends TestCase | ||
{ | ||
public function testAutoConfigure(): void | ||
{ | ||
$parameterBag = new EnvPlaceholderParameterBag(); | ||
$container = new ContainerBuilder($parameterBag); | ||
$container->setParameter('kernel.debug', true); | ||
|
||
$container->registerExtension(new MockFrameworkExtension()); | ||
$container->prependExtensionConfig('framework', [ | ||
'http_cache' => [ | ||
'default_ttl' => '%env(int:DUMMY_ENV)%', | ||
], | ||
]); | ||
|
||
$container->addCompilerPass(new ValidateEnvPlaceholdersPass()); | ||
$container->addCompilerPass(new ExampleCompilerPass()); | ||
|
||
$this->expectNotToPerformAssertions(); | ||
$container->compile(true); | ||
} | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class ExampleCompilerPass implements CompilerPassInterface | ||
{ | ||
use CompilerPassConfigTrait; | ||
|
||
public function process(ContainerBuilder $container): void | ||
{ | ||
$this->getConfig($container, 'framework'); | ||
} | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class MockFrameworkExtension implements ExtensionInterface | ||
{ | ||
public function load(array $configs, ContainerBuilder $container): void | ||
{ | ||
} | ||
|
||
public function getNamespace(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function getXsdValidationBasePath(): string|false | ||
{ | ||
return false; | ||
} | ||
|
||
public function getAlias(): string | ||
{ | ||
return 'framework'; | ||
} | ||
} |