8000 bug #15846 [FrameworkBundle] Advanced search templates of bundles (ye… · symfony/symfony@16ba457 · GitHub
[go: up one dir, main page]

Skip to content

Commit 16ba457

Browse files
committed
bug #15846 [FrameworkBundle] Advanced search templates of bundles (yethee)
This PR was submitted for the 2.8 branch but it was merged into the 2.3 branch instead (closes #15846). Discussion ---------- [FrameworkBundle] Advanced search templates of bundles | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a It uses two different locations to search templates of bundle by `TemplateFinder`, as described in the documentation. Useful for TwigBundle, in cases when uses the custom templates for error pages. Commits ------- 3ba1460 [FrameworkBundle] Advanced search templates of bundles
2 parents 25dccf1 + 3ba1460 commit 16ba457

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ private function findTemplatesInFolder($dir)
9797
*/
9898
private function findTemplatesInBundle(BundleInterface $bundle)
9999
{
100-
$templates = $this->findTemplatesInFolder($bundle->getPath().'/Resources/views');
101100
$name = $bundle->getName();
101+
$templates = array_merge(
102+
$this->findTemplatesInFolder($bundle->getPath().'/Resources/views'),
103+
$this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views')
104+
);
105+
$templates = array_unique($templates);
102106

103107
foreach ($templates as $i => $template) {
104108
$templates[$i] = $template->set('bundle', $name);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ function ($template) { return $template->getLogicalName(); },
4646
$finder->findAllTemplates()
4747
);
4848

49-
$this->assertCount(6, $templates, '->findAllTemplates() find all templates in the bundles and global folders');
49+
$this->assertCount(7, $templates, '->findAllTemplates() find all templates in the bundles and global folders');
5050
$this->assertContains('BaseBundle::base.format.engine', $templates);
5151
$this->assertContains('BaseBundle::this.is.a.template.format.engine', $templates);
5252
$this->assertContains('BaseBundle:controller:base.format.engine', $templates);
53+
$this->assertContains('BaseBundle:controller:custom.format.engine', $templates);
5354
$this->assertContains('::this.is.a.template.format.engine', $templates);
5455
$this->assertContains('::resource.format.engine', $templates);
5556
}

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/BaseBundle/views/base.format.engine

Whitespace-only changes.

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/BaseBundle/views/controller/custom.format.engine

Whitespace-only changes.

0 commit comments

Comments
 (0)
0