-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Routing][Translation][Workflow] Move some compiler passes from FrameworkBundle to components #52032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -15,10 +15,14 @@ | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
trigger_deprecation('symfony/framework-bundle', '6.4', 'The "%s" class is deprecated, use "%s" instead.', AddExpressionLanguageProvidersPass::class, \Symfony\Component\Routing\DependencyInjection\AddExpressionLanguageProvidersPass::class); | ||
|
||
/** | ||
* Registers the expression language providers. | ||
* | ||
* @author Fabien Potencier <[email protected]> | ||
* | ||
* @deprecated since Symfony 6.4, use Symfony\Component\Routing\DependencyInjection\AddExpressionLanguageProvidersPass instead. | ||
*/ | ||
class AddExpressionLanguageProvidersPass implements CompilerPassInterface | ||
{ | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -15,8 +15,12 @@ | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Translation\TranslatorBagInterface; | ||
|
||
trigger_deprecation('symfony/framework-bundle', '6.4', 'The "%s" class is deprecated, use "%s" instead.', DataCollectorTranslatorPass::class, \Symfony\Component\Translation\DependencyInjection\DataCollectorTranslatorPass::class); | ||
|
||
/** | ||
* @author Christian Flothmann <[email protected]> | ||
* | ||
* @deprecated since Symfony 6.4, use Symfony\Component\Translation\DependencyInjection\DataCollectorTranslatorPass instead. | ||
*/ | ||
class DataCollectorTranslatorPass implements CompilerPassInterface | ||
{ | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -17,8 +17,12 @@ | |
use Symfony\Component\Translation\TranslatorBagInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
trigger_deprecation('symfony/framework-bundle', '6.4', 'The "%s" class is deprecated, use "%s" instead.', LoggingTranslatorPass::class, \Symfony\Component\Translation\DependencyInjection\LoggingTranslatorPass::class); | ||
|
||
/** | ||
* @author Abdellatif Ait boudad <[email protected]> | ||
* | ||
* @deprecated since Symfony 6.4, use Symfony\Component\Translation\DependencyInjection\LoggingTranslatorPass instead. | ||
*/ | ||
class LoggingTranslatorPass implements CompilerPassInterface | ||
{ | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -15,9 +15,13 @@ | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Exception\LogicException; | ||
|
||
trigger_deprecation('symfony/framework-bundle', '6.4', 'The "%s" class is deprecated, use "%s" instead.', WorkflowGuardListenerPass::class, \Symfony\Component\Workflow\DependencyInjection\WorkflowGuardListenerPass::class); | ||
|
||
/** | ||
* @author Christian Flothmann <[email protected]> | ||
* @author Grégoire Pineau <[email protected]> | ||
* | ||
* @deprecated since Symfony 6.4, use Symfony\Component\Workflow\DependencyInjection\WorkflowGuardListenerPass instead. | ||
*/ | ||
class WorkflowGuardListenerPass implements CompilerPassInterface | ||
{ | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
36 changes: 36 additions & 0 deletions
36
src/Symfony/Component/Routing/DependencyInjection/AddExpressionLanguageProvidersPass.php
This file contains hidden or 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,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* Registers the expression language providers. | ||
* | ||
* @author Fabien Potencier <[email protected]> | ||
*/ | ||
class AddExpressionLanguageProvidersPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
if (!$container->has('router.default')) { | ||
return; | ||
} | ||
|
||
$definition = $container->findDefinition('router.default'); | ||
foreach ($container->findTaggedServiceIds('routing.expression_language_provider', true) as $id => $attributes) { | ||
$definition->addMethodCall('addExpressionLanguageProvider', [new Reference($id)]); | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...ny/Component/Routing/Tests/DependencyInjection/AddExpressionLanguageProvidersPassTest.php
This file contains hidden or 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,60 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\Tests\DependencyInjection; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\Routing\DependencyInjection\AddExpressionLanguageProvidersPass; | ||
|
||
class AddExpressionLanguageProvidersPassTest extends TestCase | ||
{ | ||
public function testProcessForRouter() | ||
{ | ||
$container = new ContainerBuilder(); | ||
$container->addCompilerPass(new AddExpressionLanguageProvidersPass()); | ||
|
||
$definition = new Definition(\stdClass::class); | ||
$definition->addTag('routing.expression_language_provider'); | ||
$container->setDefinition('some_routing_provider', $definition->setPublic(true)); | ||
|
||
$container->register('router.default', \stdClass::class)->setPublic(true); | ||
$container->compile(); | ||
|
||
$router = $container->getDefinition('router.default'); | ||
$calls = $router->getMethodCalls(); | ||
$this->assertCount(1, $calls); | ||
$this->assertEquals('addExpressionLanguageProvider', $calls[0][0]); | ||
$this->assertEquals(new Reference('some_routing_provider'), $calls[0][1][0]); | ||
} | ||
|
||
public function testProcessForRouterAlias() | ||
{ | ||
$container = new ContainerBuilder(); | ||
$container->addCompilerPass(new AddExpressionLanguageProvidersPass()); | ||
|
||
$definition = new Definition(\stdClass::class); | ||
$definition->addTag('routing.expression_language_provider'); | ||
$container->setDefinition('some_routing_provider', $definition->setPublic(true)); | ||
|
||
$container->register('my_router', \stdClass::class)->setPublic(true); | ||
$container->setAlias('router.default', 'my_router'); | ||
$container->compile(); | ||
|
||
$router = $container->getDefinition('my_router'); | ||
$calls = $router->getMethodCalls(); | ||
$this->assertCount(1, $calls); | ||
$this->assertEquals('addExpressionLanguageProvider', $calls[0][0]); | ||
$this->assertEquals(new Reference('some_routing_provider'), $calls[0][1][0]); | ||
} | ||
} |
This file contains hidden or 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
36 changes: 36 additions & 0 deletions
36
src/Symfony/Component/Translation/DependencyInjection/DataCollectorTranslatorPass.php
This file contains hidden or 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,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Translation\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Translation\TranslatorBagInterface; | ||
|
||
/** | ||
* @author Christian Flothmann <[email protected]> | ||
*/ | ||
class DataCollectorTranslatorPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
if (!$container->has('translator')) { | ||
return; | ||
} | ||
|
||
$translatorClass = $container->getParameterBag()->resolveValue($container->findDefinition('translator')->getClass()); | ||
|
||
if (!is_subclass_of($translatorClass, TranslatorBagInterface::class)) { | ||
$container->removeDefinition('translator.data_collector'); | ||
$container->removeDefinition('data_collector.translation'); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/Symfony/Component/Translation/DependencyInjection/LoggingTranslatorPass.php
This file contains hidden or 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,59 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Translation\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; | ||
use Symfony\Component\Translation\TranslatorBagInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
/** | ||
* @author Abdellatif Ait boudad <[email protected]> | ||
*/ | ||
class LoggingTranslatorPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
if (!$container->hasAlias('logger') || !$container->hasAlias('translator')) { | ||
return; | ||
} | ||
|
||
if (!$container->hasParameter('translator.logging') || !$container->getParameter('translator.logging')) { | ||
return; | ||
} | ||
|
||
$translatorAlias = $container->getAlias('translator'); | ||
$definition = $container->getDefinition((string) $translatorAlias); | ||
$class = $container->getParameterBag()->resolveValue($definition->getClass()); | ||
|
||
if (!$r = $container->getReflectionClass($class)) { | ||
throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $translatorAlias)); | ||
} | ||
|
||
if (!$r->isSubclassOf(TranslatorInterface::class) || !$r->isSubclassOf(TranslatorBagInterface::class)) { | ||
return; | ||
} | ||
|
||
$container->getDefinition('translator.logging')->setDecoratedService('translator'); | ||
$warmer = $container->getDefinition('translation.warmer'); | ||
$subscriberAttributes = $warmer->getTag('container.service_subscriber'); | ||
$warmer->clearTag('container.service_subscriber'); | ||
|
||
foreach ($subscriberAttributes as $k => $v) { | ||
if ((!isset($v['id']) || 'translator' !== $v['id']) && (!isset($v['key']) || 'translator' !== $v['key'])) { | ||
$warmer->addTag('container.service_subscriber', $v); | ||
} | ||
} | ||
$warmer->addTag('container.service_subscriber', ['key' => 'translator', 'id' => 'translator.logging.inner']); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no constructor so the argument is unused.