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 @@ -28,7 +28,6 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Validator\Validator\ValidatorInterface;
Expand Down Expand Up @@ -426,17 +425,15 @@ private function registerHttpCache(ContainerBuilder $container, array $config, X

$loader->load('http_cache_tags.xml');

$references = [];
foreach ($config['http_cache']['invalidation']['varnish_urls'] as $url) {
$id = sprintf('api_platform.http_cache.purger.varnish_client.%s', $url);
$references[] = new Reference($id);

$definitions = [];
foreach ($config['http_cache']['invalidation']['varnish_urls'] as $key => $url) {
$definition = new ChildDefinition('api_platform.http_cache.purger.varnish_client');
$definition->addArgument(['base_uri' => $url]);
$container->setDefinition($id, $definition);

$definitions[] = $definition;
}

$container->getDefinition('api_platform.http_cache.purger.varnish')->addArgument($references);
$container->getDefinition('api_platform.http_cache.purger.varnish')->addArgument($definitions);
$container->setAlias('api_platform.http_cache.purger', 'api_platform.http_cache.purger.varnish');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function testNotPrependWhenNameConverterIsNotConfigured()

public function testLoadDefaultConfig()
{
$containerBuilderProphecy = $this->getDefaultContainerBuilderProphecy();
$containerBuilderProphecy = $this->getBaseContainerBuilderProphecy();
$containerBuilder = $containerBuilderProphecy->reveal();

$this->extension->load(self::DEFAULT_CONFIG, $containerBuilder);
Expand All @@ -167,7 +167,7 @@ public function testSetNameConverter()
{
$nameConverterId = 'test.name_converter';

$containerBuilderProphecy = $this->getDefaultContainerBuilderProphecy();
$containerBuilderProphecy = $this->getBaseContainerBuilderProphecy();
$containerBuilderProphecy->setAlias('api_platform.name_converter', $nameConverterId)->shouldBeCalled();
$containerBuilder = $containerBuilderProphecy->reveal();

Expand All @@ -176,7 +176,7 @@ public function testSetNameConverter()

public function testEnableFosUser()
{
$containerBuilderProphecy = $this->getDefaultContainerBuilderProphecy();
$containerBuilderProphecy = $this->getBaseContainerBuilderProphecy();
$containerBuilderProphecy->getParameter('kernel.bundles')->willReturn([
'DoctrineBundle' => DoctrineBundle::class,
'FOSUserBundle' => FOSUserBundle::class,
Expand Down Expand Up @@ -208,7 +208,7 @@ public function testFosUserPriority()

public function testEnableNelmioApiDoc()
{
$containerBuilderProphecy = $this->getDefaultContainerBuilderProphecy();
$containerBuilderProphecy = $this->getBaseContainerBuilderProphecy();
$containerBuilderProphecy->getParameter('kernel.bundles')->willReturn([
'DoctrineBundle' => DoctrineBundle::class,
'NelmioApiDocBundle' => NelmioApiDocBundle::class,
Expand All @@ -222,7 +222,7 @@ public function testEnableNelmioApiDoc()

public function testEnableSecurity()
{
$containerBuilderProphecy = $this->getDefaultContainerBuilderProphecy();
$containerBuilderProphecy = $this->getBaseContainerBuilderProphecy();
$containerBuilderProphecy->getParameter('kernel.bundles')->willReturn([
'DoctrineBundle' => DoctrineBundle::class,
'SecurityBundle' => SecurityBundle::class,
Expand Down Expand Up @@ -260,7 +260,7 @@ public function testResourcesToWatchWithNonExistentFile()

public function testDisableEagerLoadingExtension()
{
$containerBuilderProphecy = $this->getDefaultContainerBuilderProphecy();
$containerBuilderProphecy = $this->getBaseContainerBuilderProphecy();
$containerBuilderProphecy->setParameter('api_platform.eager_loading.enabled', false)->shouldBeCalled();
$containerBuilderProphecy->removeDefinition('api_platform.doctrine.orm.query_extension.eager_loading')->shouldBeCalled();
$containerBuilderProphecy->removeDefinition('api_platform.doctrine.orm.query_extension.filter_eager_loading')->shouldBeCalled();
Expand Down Expand Up @@ -572,16 +572,4 @@ private function getBaseContainerBuilderProphecy()

return $containerBuilderProphecy;
}

private function getDefaultContainerBuilderProphecy()
{
$containerBuilderProphecy = $this->getBaseContainerBuilderProphecy();

$containerBuilderProphecy
->setDefinition('api_platform.http_cache.purger.varnish_client.test', Argument::type(Definition::class))
->shouldBeCalled()
;

return $containerBuilderProphecy;
}
}