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
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ private function addToCollector(string $id, string $name, ContainerBuilder $cont
}
$recorder->setArguments([new Reference($innerId = $id.$this->cachePoolRecorderInnerSuffix)]);

foreach ($definition->getMethodCalls() as [$method, $args]) {
if ('setCallbackWrapper' !== $method || !$args[0] instanceof Definition || !($args[0]->getArguments()[2] ?? null) instanceof Definition) {
continue;
}
if ([new Reference($id), 'setCallbackWrapper'] == $args[0]->getArguments()[2]->getFactory()) {
$args[0]->getArguments()[2]->setFactory([new Reference($innerId), 'setCallbackWrapper']);
}
}

$definition->setTags([]);
$definition->setPublic(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\Cache\Tests\Fixtures\ArrayCache;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class CacheCollectorPassTest extends TestCase
Expand All @@ -31,6 +32,13 @@ public function testProcess()
$container = new ContainerBuilder();
$container
->register('fs', FilesystemAdapter::class)
->addMethodCall('setCallbackWrapper', [(new Definition())
->addArgument(null)
->addArgument(null)
->addArgument((new Definition('callable'))
->setFactory([new Reference('fs'), 'setCallbackWrapper'])
),
])
->addTag('cache.pool');
$container
->register('tagged_fs', TagAwareAdapter::class)
Expand Down Expand Up @@ -60,6 +68,9 @@ public function testProcess()
$this->assertSame(TagAwareAdapter::class, $container->getDefinition('php')->getClass());

$this->assertFalse($collector->isPublic(), 'The "data_collector.cache" should be private after processing');

$innerFs = $container->getDefinition('fs.recorder_inner');
$this->assertEquals([new Reference('fs.recorder_inner'), 'setCallbackWrapper'], $innerFs->getMethodCalls()[0][1][0]->getArgument(2)->getFactory());
}

public function testProcessCacheObjectsAreDecorated()
Expand Down