Revert "bug #9112 Prepend Child Bundle paths before the parent (trsteel88)"
This reverts commitcfa99a96dd
, reversing changes made tof8965b6499
.
This commit is contained in:
parent
f36f666548
commit
8c1735d5ff
@ -69,26 +69,13 @@ class TwigExtension extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
// register bundles as Twig namespaces
|
// register bundles as Twig namespaces
|
||||||
$bundles = $this->getBundlesByChildPriority($container);
|
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
|
||||||
foreach ($bundles as $bundle => $bundleReflection) {
|
|
||||||
/** @var \Symfony\Component\HttpKernel\Bundle\BundleInterface $bundleInstance */
|
|
||||||
$bundleInstance = $bundleReflection->newInstance();
|
|
||||||
|
|
||||||
if (null !== $parentBundle = $bundleInstance->getParent()) {
|
|
||||||
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$bundle.'/views')) {
|
|
||||||
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $parentBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_dir($dir = $bundleInstance->getPath().'/Resources/views')) {
|
|
||||||
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $parentBundle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$bundle.'/views')) {
|
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$bundle.'/views')) {
|
||||||
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
|
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_dir($dir = $bundleInstance->getPath().'/Resources/views')) {
|
$reflection = new \ReflectionClass($class);
|
||||||
|
if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/views')) {
|
||||||
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
|
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,36 +130,12 @@ class TwigExtension extends Extension
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ContainerBuilder $container
|
|
||||||
* @return array | \ReflectionClass[]
|
|
||||||
*/
|
|
||||||
private function getBundlesByChildPriority(ContainerBuilder $container)
|
|
||||||
{
|
|
||||||
$childBundles = array();
|
|
||||||
$parentBundles = array();
|
|
||||||
|
|
||||||
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
|
|
||||||
$reflection = new \ReflectionClass($class);
|
|
||||||
|
|
||||||
$bundleInstance = $reflection->newInstance();
|
|
||||||
if (null === $bundleInstance->getParent()) {
|
|
||||||
$parentBundles[$bundle] = $reflection;
|
|
||||||
} else {
|
|
||||||
$childBundles[$bundle] = $reflection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_merge($childBundles, $parentBundles);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle)
|
private function addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle)
|
||||||
{
|
{
|
||||||
$name = $bundle;
|
$name = $bundle;
|
||||||
if ('Bundle' === substr($name, -6)) {
|
if ('Bundle' === substr($name, -6)) {
|
||||||
$name = substr($name, 0, -6);
|
$name = substr($name, 0, -6);
|
||||||
}
|
}
|
||||||
|
|
||||||
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir, $name));
|
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir, $name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user