Skip to content

Commit 4d40852

Browse files
committed
bug #14262 [TwigBundle] Refresh twig paths when resources change. (aitboudad)
This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes #14262). Discussion ---------- [TwigBundle] Refresh twig paths when resources change. | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Fixed tickets | ~ | Tests pass? | yes | License | MIT Commits ------- cafb0d7 [TwigBundle] Refresh twig paths when resources change.
2 parents dd2fb85 + cafb0d7 commit 4d40852

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\TwigBundle\DependencyInjection;
1313

1414
use Symfony\Component\Config\FileLocator;
15+
use Symfony\Component\Config\Resource\DirectoryResource;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Reference;
1718
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@@ -66,22 +67,26 @@ public function load(array $configs, ContainerBuilder $container)
6667
} else {
6768
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
6869
}
70+
$container->addResource(new DirectoryResource($path));
6971
}
7072

7173
// register bundles as Twig namespaces
7274
foreach ($container->getParameter('kernel.bundles') as $bundle => $class) {
7375
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$bundle.'/views')) {
7476
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
77+
$container->addResource(new DirectoryResource($dir));
7578
}
7679

7780
$reflection = new \ReflectionClass($class);
7881
if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/views')) {
7982
$this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle);
83+
$container->addResource(new DirectoryResource($dir));
8084
}
8185
}
8286

8387
if (is_dir($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) {
8488
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir));
89+
$container->addResource(new DirectoryResource($dir));
8590
}
8691

8792
if (!empty($config['globals'])) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy