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

Skip to content

Commit e5629d7

Browse files
committed
Merge branch '2.3' into 2.4
* 2.3: Revert "bug #9112 Prepend Child Bundle paths before the parent (trsteel88)"
2 parents e10d9e9 + 8c1735d commit e5629d7

File tree

1 file changed

+3
-40
lines changed

1 file changed

+3
-40
lines changed

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

+3-40
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,13 @@ public function load(array $configs, ContainerBuilder $container)
6969
}
7070

7171
// register bundles as Twig namespaces
72-
$bundles = $this->getBundlesByChildPriority($container);
73-
foreach ($bundles as $bundle => $bundleReflection) {
74-
/** @var \Symfony\Component\HttpKernel\Bundle\BundleInterface $bundleInstance */
75-
$bundleInstance = $bundleReflection->newInstance();
76-
77-
if (null !== $parentBundle = $bundleInstance->getParent()) {
78-
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$bundle.'/views')) {
79-
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $parentBundle);
80-
}
81-
82-
if (is_dir($dir = $bundleInstance->getPath().'/Resources/views')) {
83-
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $parentBundle);
84-
}
85-
}
86-
72+
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
8773
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$bundle.'/views')) {
8874
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
8975
}
9076

91-
if (is_dir($dir = $bundleInstance->getPath().'/Resources/views')) {
77+
$reflection = new \ReflectionClass($class);
78+
if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/views')) {
9279
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
9380
}
9481
}
@@ -143,36 +130,12 @@ public function load(array $configs, ContainerBuilder $container)
143130
));
144131
}
145132

146-
/**
147-
* @param ContainerBuilder $container
148-
* @return array | \ReflectionClass[]
149-
*/
150-
private function getBundlesByChildPriority(ContainerBuilder $container)
151-
{
152-
$childBundles = array();
153-
$parentBundles = array();
154-
155-
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
156-
$reflection = new \ReflectionClass($class);
157-
158-
$bundleInstance = $reflection->newInstance();
159-
if (null === $bundleInstance->getParent()) {
160-
$parentBundles[$bundle] = $reflection;
161-
} else {
162-
$childBundles[$bundle] = $reflection;
163-
}
164-
}
165-
166-
return array_merge($childBundles, $parentBundles);
167-
}
168-
169133
private function addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle)
170134
{
171135
$name = $bundle;
172136
if ('Bundle' === substr($name, -6)) {
173137
$name = substr($name, 0, -6);
174138
}
175-
176139
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir, $name));
177140
}
178141

0 commit comments

Comments
 (0)