Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
do not wire namespaces for the ArrayAdapter
  • Loading branch information
xabbuh committed Jul 10, 2017
commit 9380614de9a7f7ef226e94d22611153070b14e83
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;

use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -70,7 +71,7 @@ public function process(ContainerBuilder $container)
}
$i = 0;
foreach ($attributes as $attr) {
if (isset($tags[0][$attr])) {
if (isset($tags[0][$attr]) && ('namespace' !== $attr || ArrayAdapter::class !== $adapter->getClass())) {
$pool->replaceArgument($i++, $tags[0][$attr]);
}
unset($tags[0][$attr]);
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\CachePoolPass;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
Expand Down Expand Up @@ -49,6 +50,24 @@ public function testNamespaceArgumentIsReplaced()
$this->assertSame('D07rhFx97S', $cachePool->getArgument(0));
}

public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
{
$container = new ContainerBuilder();
$container->setParameter('kernel.environment', 'prod');
$container->setParameter('kernel.name', 'app');
$container->setParameter('kernel.root_dir', 'foo');

$container->register('cache.adapter.array', ArrayAdapter::class)->addArgument(0);

$cachePool = new DefinitionDecorator('cache.adapter.array');
$cachePool->addTag('cache.pool');
$container->setDefinition('app.cache_pool', $cachePool);

$this->cachePoolPass->process($container);

$this->assertCount(0, $container->getDefinition('app.cache_pool')->getArguments());
}

public function testArgsAreReplaced()
{
$container = new ContainerBuilder();
Expand Down