Skip to content

Commit 03f66f2

Browse files
committed
Changing DI alias to ez_platform_cache
1 parent 8e33227 commit 03f66f2

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Configuration implements ConfigurationInterface
1818
public function getConfigTreeBuilder()
1919
{
2020
$treeBuilder = new TreeBuilder();
21-
$rootNode = $treeBuilder->root('ez_systems_platform_http_cache');
21+
$rootNode = $treeBuilder->root('ez_platform_http_cache');
2222

2323
// Here you should define the parameters that are allowed to
2424
// configure your bundle. See the documentation linked above for

src/DependencyInjection/EzSystemsPlatformHttpCacheExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ public function prepend(ContainerBuilder $container)
3535
$container->prependExtensionConfig('fos_http_cache', $config);
3636
$container->addResource(new FileResource($configFile));
3737
}
38+
39+
public function getAlias()
40+
{
41+
return 'ez_platform_cache';
42+
}
3843
}

src/EzSystemsPlatformHttpCacheBundle.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use EzSystems\PlatformHttpCacheBundle\DependencyInjection\Compiler\DriverPass;
88
use Symfony\Component\DependencyInjection\ContainerBuilder;
99
use Symfony\Component\HttpKernel\Bundle\Bundle;
10+
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
1011

1112
class EzSystemsPlatformHttpCacheBundle extends Bundle
1213
{
@@ -18,4 +19,28 @@ public function build(ContainerBuilder $container)
1819
$container->addCompilerPass(new KernelPass());
1920
$container->addCompilerPass(new DriverPass());
2021
}
22+
23+
public function getContainerExtension()
24+
{
25+
// We need to overload Bundle::getContainerExtension() because we change DI alias in
26+
// EzSystemsPlatformHttpCacheExtension::getAlias()
27+
// Bundle::getContainerExtension() has a check that alias matches underscored version of the bundle name
28+
if (null === $this->extension) {
29+
$extension = $this->createContainerExtension();
30+
31+
if (null !== $extension) {
32+
if (!$extension instanceof ExtensionInterface) {
33+
throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_class($extension)));
34+
}
35+
36+
$this->extension = $extension;
37+
} else {
38+
$this->extension = false;
39+
}
40+
}
41+
42+
if ($this->extension) {
43+
return $this->extension;
44+
}
45+
}
2146
}

0 commit comments

Comments
 (0)