Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Skip tags on abstract definitions when relevant #22388

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function process(ContainerBuilder $container)

$clearers = array();
foreach ($container->findTaggedServiceIds('kernel.cache_clearer') as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
$clearers[] = new Reference($id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public function process(ContainerBuilder $container)
if ($container->has('router')) {
$definition = $container->findDefinition('router');
foreach ($container->findTaggedServiceIds('routing.expression_language_provider') as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
$definition->addMethodCall('addExpressionLanguageProvider', array(new Reference($id)));
}
}
Expand All @@ -39,6 +42,9 @@ public function process(ContainerBuilder $container)
if ($container->has('security.access.expression_voter')) {
$definition = $container->findDefinition('security.access.expression_voter');
foreach ($container->findTaggedServiceIds('security.expression_language_provider') as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
$definition->addMethodCall('addExpressionLanguageProvider', array(new Reference($id)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public function process(ContainerBuilder $container)
$pools = array();

foreach ($container->findTaggedServiceIds('cache.pool') as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
$pools[$id] = new Reference($id);
foreach (array_reverse($attributes) as $attr) {
if (isset($attr['clearer'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public function process(ContainerBuilder $container)
$collectors = new \SplPriorityQueue();
$order = PHP_INT_MAX;
foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
$template = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function process(ContainerBuilder $container)
if ($container->hasDefinition('templating.engine.php')) {
$helpers = array();
foreach ($container->findTaggedServiceIds('templating.helper') as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
if (isset($attributes[0]['alias'])) {
$helpers[$attributes[0]['alias']] = $id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function process(ContainerBuilder $container)
$definition = $container->getDefinition('translation.writer');

foreach ($container->findTaggedServiceIds('translation.dumper') as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
$definition->addMethodCall('addDumper', array($attributes[0]['alias'], new Reference($id)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public function process(ContainerBuilder $container)
$definition = $container->getDefinition('translation.extractor');

foreach ($container->findTaggedServiceIds('translation.extractor') as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
if (!isset($attributes[0]['alias'])) {
throw new RuntimeException(sprintf('The alias for the tag "translation.extractor" of service "%s" must be set.', $id));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function process(ContainerBuilder $container)
$loaders = array();
$loaderRefs = array();
foreach ($container->findTaggedServiceIds('translation.loader') as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
$loaderRefs[$id] = new Reference($id);
$loaders[$id][] = $attributes[0]['alias'];
if (isset($attributes[0]['legacy-alias'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function testThatCacheWarmersAreProcessedInPriorityOrder()
->will($this->returnValue($services));
$container->expects($this->atLeastOnce())
->method('getDefinition')
->with('cache_warmer')
->will($this->returnValue($definition));
$container->expects($this->atLeastOnce())
->method('hasDefinition')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function testThatCheckersAreProcessedInPriorityOrder()
->will($this->returnValue($services));
$container->expects($this->atLeastOnce())
->method('getDefinition')
->with('config_cache_factory')
->will($this->returnValue($definition));

$definition->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\PropertyInfoPass;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

/**
Expand All @@ -34,12 +35,16 @@ public function testServicesAreOrderedAccordingToPriority()
new Reference('n3'),
);

$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition'))->getMock();

$container
->expects($this->any())
->method('findTaggedServiceIds')
->will($this->returnValue($services));
$container
->expects($this->any())
->method('getDefinition')
->will($this->returnValue(new Definition()));

$propertyInfoPass = new PropertyInfoPass();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass;

Expand Down Expand Up @@ -61,7 +62,7 @@ public function testThrowExceptionWhenNoEncoders()
array()
));

$container->expects($this->once())
$container->expects($this->atLeastOnce())
->method('getDefinition')
->will($this->returnValue($definition));

Expand All @@ -85,11 +86,14 @@ public function testServicesAreOrderedAccordingToPriority()
new Reference('n3'),
);

$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition'))->getMock();

$container->expects($this->any())
->method('findTaggedServiceIds')
->will($this->returnValue($services));
$container->expects($this->any())
->method('getDefinition')
->will($this->returnValue(new Definition()));

$serializerPass = new SerializerPass();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function process(ContainerBuilder $container)
$calls = $definition->getMethodCalls();
$definition->setMethodCalls(array());
foreach ($container->findTaggedServiceIds('twig.extension') as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
$definition->addMethodCall('addExtension', array(new Reference($id)));
}
$definition->setMethodCalls(array_merge($definition->getMethodCalls(), $calls));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,28 @@ public function process(ContainerBuilder $container)
return;
}

// register additional template loaders
$loaderIds = $container->findTaggedServiceIds('twig.loader');
$prioritizedLoaders = array();
$found = 0;

if (count($loaderIds) === 0) {
foreach ($container->findTaggedServiceIds('twig.loader') as $id => $tags) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
foreach ($tags as $tag) {
$priority = isset($tag['priority']) ? $tag['priority'] : 0;
$prioritizedLoaders[$priority][] = $id;
}
++$found;
}

if (!$found) {
throw new LogicException('No twig loaders found. You need to tag at least one loader with "twig.loader"');
}

if (count($loaderIds) === 1) {
$container->setAlias('twig.loader', key($loaderIds));
if (1 === $found) {
$container->setAlias('twig.loader', current($prioritizedLoaders)[0]);
} else {
$chainLoader = $container->getDefinition('twig.loader.chain');

$prioritizedLoaders = array();

foreach ($loaderIds as $id => $tags) {
foreach ($tags as $tag) {
$priority = isset($tag['priority']) ? $tag['priority'] : 0;
$prioritizedLoaders[$priority][] = $id;
}
}

krsort($prioritizedLoaders);

foreach ($prioritizedLoaders as $loaders) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function testMapperPassWithOneTaggedLoaders()
->method('findTaggedServiceIds')
->with('twig.loader')
->will($this->returnValue($serviceIds));
$this->builder->expects($this->once())
->method('getDefinition')
->will($this->returnValue(new Definition()));
$this->builder->expects($this->once())
->method('setAlias')
->with('twig.loader', 'test_loader_1');
Expand All @@ -79,10 +82,11 @@ public function testMapperPassWithTwoTaggedLoaders()
->method('findTaggedServiceIds')
->with('twig.loader')
->will($this->returnValue($serviceIds));
$this->builder->expects($this->once())
$this->builder->expects($this->exactly(3))
->method('getDefinition')
->with('twig.loader.chain')
->will($this->returnValue($this->chainLoader));
->withConsecutive(array('test_loader_1'), array('test_loader_2'), array('twig.loader.chain'))
->willReturnOnConsecutiveCalls(new Definition(), new Definition(), $this->chainLoader);

$this->builder->expects($this->once())
->method('setAlias')
->with('twig.loader', 'twig.loader.chain');
Expand Down Expand Up @@ -115,10 +119,10 @@ public function testMapperPassWithTwoTaggedLoadersWithPriority()
->method('findTaggedServiceIds')
->with('twig.loader')
->will($this->returnValue($serviceIds));
$this->builder->expects($this->once())
$this->builder->expects($this->exactly(3))
->method('getDefinition')
->with('twig.loader.chain')
->will($this->returnValue($this->chainLoader));
->withConsecutive(array('test_loader_1'), array('test_loader_2'), array('twig.loader.chain'))
->willReturnOnConsecutiveCalls(new Definition(), new Definition(), $this->chainLoader);
$this->builder->expects($this->once())
->method('setAlias')
->with('twig.loader', 'twig.loader.chain');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public function testThatCheckersAreProcessedInPriorityOrder()
->will($this->returnValue($services));
$container->expects($this->atLeastOnce())
->method('getDefinition')
->with('config_cache_factory')
->will($this->returnValue($definition));

$definition->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ private function findAndSortTaggedServices($tagName, ContainerBuilder $container
$services = array();

foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $tags) {
if ($container->getDefinition($serviceId)->isAbstract()) {
continue;
}
foreach ($tags as $attributes) {
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
$services[$priority][] = new Reference($serviceId);
Expand Down
3 changes: 3 additions & 0 deletions 3 src/Symfony/Component/Form/DependencyInjection/FormPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ private function processFormTypes(ContainerBuilder $container, Definition $defin
// Builds an array with fully-qualified type class names as keys and service IDs as values
foreach ($container->findTaggedServiceIds($this->formTypeTag) as $serviceId => $tag) {
$serviceDefinition = $container->getDefinition($serviceId);
if ($serviceDefinition->isAbstract()) {
continue;
}

// Add form type service to the service locator
$servicesMap[$serviceDefinition->getClass()] = new Reference($serviceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\PropertyInfo\Tests\DependencyInjection;

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;

Expand All @@ -31,12 +32,16 @@ public function testServicesAreOrderedAccordingToPriority()
new Reference('n3'),
);

$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition'))->getMock();

$container
->expects($this->any())
->method('findTaggedServiceIds')
->will($this->returnValue($services));
$container
->expects($this->any())
->method('getDefinition')
->will($this->returnValue(new Definition()));

$propertyInfoPass = new PropertyInfoPass();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public function process(ContainerBuilder $container)
$definition = $container->getDefinition($this->resolverServiceId);

foreach ($container->findTaggedServiceIds($this->loaderTag) as $id => $attributes) {
if ($container->getDefinition($id)->isAbstract()) {
continue;
}
$definition->addMethodCall('addLoader', array(new Reference($id)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Serializer\Tests\DependencyInjection;

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Serializer\DependencyInjection\SerializerPass;

Expand Down Expand Up @@ -59,7 +60,7 @@ public function testThrowExceptionWhenNoEncoders()
array()
));

$container->expects($this->once())
$container->expects($this->atLeastOnce())
->method('getDefinition')
->will($this->returnValue($definition));

Expand All @@ -83,11 +84,14 @@ public function testServicesAreOrderedAccordingToPriority()
new Reference('n3'),
);

$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds'))->getMock();
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->setMethods(array('findTaggedServiceIds', 'getDefinition'))->getMock();

$container->expects($this->any())
->method('findTaggedServiceIds')
->will($this->returnValue($services));
$container->expects($this->any())
->method('getDefinition')
->will($this->returnValue(new Definition()));

$serializerPass = new SerializerPass();

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.