Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 16bc18f

Browse filesBrowse files
committed
Caching missed templates in default path on warmup
1 parent b9a3c87 commit 16bc18f
Copy full SHA for 16bc18f

File tree

Expand file treeCollapse file tree

3 files changed

+7
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+7
-2
lines changed

‎src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<argument type="service" id="kernel" />
4242
<argument>%kernel.root_dir%</argument>
4343
<argument type="collection" /> <!-- Twig paths -->
44+
<argument>%twig.default_path%</argument>
4445
</service>
4546

4647
<service id="twig.template_cache_warmer" class="Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheWarmer">

‎src/Symfony/Bundle/TwigBundle/TemplateIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/TemplateIterator.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@ class TemplateIterator implements \IteratorAggregate
2525
private $rootDir;
2626
private $templates;
2727
private $paths;
28+
private $defaultPath;
2829

2930
/**
3031
* @param KernelInterface $kernel A KernelInterface instance
3132
* @param string $rootDir The directory where global templates can be stored
3233
* @param array $paths Additional Twig paths to warm
3334
*/
34-
public function __construct(KernelInterface $kernel, $rootDir, array $paths = array())
35+
public function __construct(KernelInterface $kernel, $rootDir, array $paths = array(), $defaultPath = null)
3536
{
3637
$this->kernel = $kernel;
3738
$this->rootDir = $rootDir;
3839
$this->paths = $paths;
40+
$this->defaultPath = $defaultPath;
3941
}
4042

4143
/**
@@ -48,6 +50,7 @@ public function getIterator()
4850
}
4951

5052
$this->templates = $this->findTemplatesInDirectory($this->rootDir.'/Resources/views');
53+
$this->templates = array_merge($this->templates, $this->findTemplatesInDirectory($this->defaultPath));
5154
foreach ($this->kernel->getBundles() as $bundle) {
5255
$name = $bundle->getName();
5356
if ('Bundle' === substr($name, -6)) {

‎src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ public function testGetIterator()
2525
$kernel->expects($this->any())->method('getBundles')->will($this->returnValue(array(
2626
$bundle,
2727
)));
28-
$iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', array(__DIR__.'/Fixtures/templates/Foo' => 'Foo'));
28+
$iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', array(__DIR__.'/Fixtures/templates/Foo' => 'Foo'), __DIR__.'/DependencyInjection/Fixtures/templates');
2929

3030
$sorted = iterator_to_array($iterator);
3131
sort($sorted);
3232
$this->assertEquals(
3333
array(
3434
'@Bar/index.html.twig',
3535
'@Foo/index.html.twig',
36+
'bundles/TwigBundle/layout.html.twig',
3637
'layout.html.twig',
3738
'sub/sub.html.twig',
3839
),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.