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 4fcbb69

Browse filesBrowse files
committed
[FrameworkBundle] Cache warmer skips global templates
1 parent 1045717 commit 4fcbb69
Copy full SHA for 4fcbb69

File tree

Expand file treeCollapse file tree

17 files changed

+38
-32
lines changed
Filter options
Expand file treeCollapse file tree

17 files changed

+38
-32
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,26 @@ public function findAllTemplates()
5858
$templates = array_merge($templates, $this->findTemplatesInBundle($bundle));
5959
}
6060

61-
$templates = array_merge($templates, $this->findTemplatesInFolder($this->rootDir.'/views'));
61+
$templates = array_merge($templates, $this->findTemplatesInFolder($this->rootDir, 'bundles'));
6262

6363
return $this->templates = $templates;
6464
}
6565

6666
/**
6767
* Find templates in the given directory.
6868
*
69-
* @param string $dir The folder where to look for templates
69+
* @param string $dir The folder where to look for templates
70+
* @param string $excludeDir A subfolder of $folder to exclude
7071
*
7172
* @return TemplateReferenceInterface[]
7273
*/
73-
private function findTemplatesInFolder($dir)
74+
private function findTemplatesInFolder($dir, $excludeDir = null)
7475
{
7576
$templates = array();
7677

7778
if (is_dir($dir)) {
7879
$finder = new Finder();
79-
foreach ($finder->files()->followLinks()->in($dir) as $file) {
80+
foreach ($finder->files()->followLinks()->in($dir)->exclude($excludeDir) as $file) {
8081
$template = $this->parser->parse($file->getRelativePathname());
8182
if (false !== $template) {
8283
$templates[] = $template;
@@ -99,7 +100,7 @@ private function findTemplatesInBundle(BundleInterface $bundle)
99100
$name = $bundle->getName();
100101
$templates = array_unique(array_merge(
101102
$this->findTemplatesInFolder($bundle->getPath().'/Resources/views'),
102-
$this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views')
103+
$this->findTemplatesInFolder($this->rootDir.'/bundles/'.$name)
103104
));
104105

105106
foreach ($templates as $i => $template) {

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040

4141
<service id="file_locator" class="Symfony\Component\HttpKernel\Config\FileLocator">
4242
<argument type="service" id="kernel" />
43-
<argument>%kernel.root_dir%/Resources</argument>
43+
<argument>%kernel.project_dir%/src/Resources</argument>
4444
<argument type="collection">
45-
<argument>%kernel.root_dir%</argument>
45+
<argument>%kernel.project_dir%</argument>
4646
</argument>
4747
</service>
4848
<service id="Symfony\Component\HttpKernel\Config\FileLocator" alias="file_locator" />

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<service id="templating.finder" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder">
2727
<argument type="service" id="kernel" />
2828
<argument type="service" id="templating.filename_parser" />
29-
<argument>%kernel.root_dir%/Resources</argument>
29+
<argument>%kernel.project_dir%/templates</argument>
3030
</service>
3131

3232
<service id="templating.cache_warmer.template_paths" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer">

‎src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function getPath()
4444

4545
$path = (empty($controller) ? '' : $controller.'/').$this->get('name').'.'.$this->get('format').'.'.$this->get('engine');
4646

47-
return empty($this->parameters['bundle']) ? 'views/'.$path : '@'.$this->get('bundle').'/Resources/views/'.$path;
47+
return empty($this->parameters['bundle']) ? 'templates/'.$path : '@'.$this->get('bundle').'/Resources/views/'.$path;
4848
}
4949

5050
/**

‎src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testFindAllTemplates()
3939

4040
$parser = new TemplateFilenameParser();
4141

42-
$finder = new TemplateFinder($kernel, $parser, __DIR__.'/../Fixtures/Resources');
42+
$finder = new TemplateFinder($kernel, $parser, __DIR__.'/../Fixtures/Resources/templates');
4343

4444
$templates = array_map(
4545
function ($template) { return $template->getLogicalName(); },
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

33
return array(
4-
'bundle:controller:name.format.engine' => __DIR__.'/../Fixtures/Resources/views/this.is.a.template.format.engine',
4+
'bundle:controller:name.format.engine' => __DIR__.'/../Fixtures/Resources/templates/this.is.a.template.format.engine',
55
);

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AppKernel.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public function registerBundles()
5454
return include $filename;
5555
}
5656

57+
public function getProjectDir()
58+
{
59+
return dirname(__DIR__);
60+
}
61+
5762
public function getRootDir()
5863
{
5964
return __DIR__;

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/views/fragment.html.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/views/fragment.html.php
-14Lines changed: 0 additions & 14 deletions
This file was deleted.
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php echo $this->get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::inlinedAction', array(
2+
'options' => array(
3+
'bar' => $bar,
4+
'eleven' => 11,
5+
),
6+
)));
7+
?>--<?php
8+
echo $this->get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::customformatAction', array('_format' => 'html')));
9+
?>--<?php
10+
echo $this->get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::customlocaleAction', array('_locale' => 'es')));
11+
?>--<?php
12+
$app->getRequest()->setLocale('fr');
13+
echo $this->get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::forwardlocaleAction'));
14+
?>

‎src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testLocateATemplateFromCacheDir()
4646

4747
$locator = new TemplateLocator($fileLocator, __DIR__.'/../../Fixtures');
4848

49-
$this->assertEquals(realpath(__DIR__.'/../../Fixtures/Resources/views/this.is.a.template.format.engine'), $locator->locate($template));
49+
$this->assertEquals(realpath(__DIR__.'/../../Fixtures/Resources/templates/this.is.a.template.format.engine'), $locator->locate($template));
5050
}
5151

5252
public function testThrowsExceptionWhenTemplateNotFound()

‎src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ public function parseProvider()
6262
array('FooBundle:Post:index.xml.php', 'FooBundle:Post:index.xml.php', '@FooBundle/Resources/views/Post/index.xml.php', new TemplateReference('FooBundle', 'Post', 'index', 'xml', 'php')),
6363
array('SensioFooBundle:Post:index.html.php', 'SensioFooBundle:Post:index.html.php', '@SensioFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioFooBundle', 'Post', 'index', 'html', 'php')),
6464
array('SensioCmsFooBundle:Post:index.html.php', 'SensioCmsFooBundle:Post:index.html.php', '@SensioCmsFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')),
65-
array(':Post:index.html.php', ':Post:index.html.php', 'views/Post/index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')),
66-
array('::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
67-
array('index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
65+
array(':Post:index.html.php', ':Post:index.html.php', 'templates/Post/index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')),
66+
array('::index.html.php', '::index.html.php', 'templates/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
67+
array('index.html.php', '::index.html.php', 'templates/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
6868
array('FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')),
6969
array('@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', new BaseTemplateReference('@FooBundle/Resources/views/layout.html.twig', 'twig')),
7070
array('@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', new BaseTemplateReference('@FooBundle/Foo/layout.html.twig', 'twig')),
7171
array('name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')),
7272
array('name', 'name', 'name', new BaseTemplateReference('name')),
73-
array('default/index.html.php', '::default/index.html.php', 'views/default/index.html.php', new TemplateReference(null, null, 'default/index', 'html', 'php')),
73+
array('default/index.html.php', '::default/index.html.php', 'templates/default/index.html.php', new TemplateReference(null, null, 'default/index', 'html', 'php')),
7474
);
7575
}
7676

‎src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public function getTemplateToPathProvider()
2929
return array(
3030
array(new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php'), '@FooBundle/Resources/views/Post/index.html.php'),
3131
array(new TemplateReference('FooBundle', '', 'index', 'html', 'twig'), '@FooBundle/Resources/views/index.html.twig'),
32-
array(new TemplateReference('', 'Post', 'index', 'html', 'php'), 'views/Post/index.html.php'),
33-
array(new TemplateReference('', '', 'index', 'html', 'php'), 'views/index.html.php'),
32+
array(new TemplateReference('', 'Post', 'index', 'html', 'php'), 'templates/Post/index.html.php'),
33+
array(new TemplateReference('', '', 'index', 'html', 'php'), 'templates/index.html.php'),
3434
);
3535
}
3636
}

0 commit comments

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