[FrameworkBundle] Advanced search templates of bundles
It uses two different locations to search templates of bundle, as described in the documentation.
This commit is contained in:
parent
25dccf1bb5
commit
3ba14604a7
@ -97,8 +97,12 @@ class TemplateFinder implements TemplateFinderInterface
|
|||||||
*/
|
*/
|
||||||
private function findTemplatesInBundle(BundleInterface $bundle)
|
private function findTemplatesInBundle(BundleInterface $bundle)
|
||||||
{
|
{
|
||||||
$templates = $this->findTemplatesInFolder($bundle->getPath().'/Resources/views');
|
|
||||||
$name = $bundle->getName();
|
$name = $bundle->getName();
|
||||||
|
$templates = array_merge(
|
||||||
|
$this->findTemplatesInFolder($bundle->getPath().'/Resources/views'),
|
||||||
|
$this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views')
|
||||||
|
);
|
||||||
|
$templates = array_unique($templates);
|
||||||
|
|
||||||
foreach ($templates as $i => $template) {
|
foreach ($templates as $i => $template) {
|
||||||
$templates[$i] = $template->set('bundle', $name);
|
$templates[$i] = $template->set('bundle', $name);
|
||||||
|
@ -46,10 +46,11 @@ class TemplateFinderTest extends TestCase
|
|||||||
$finder->findAllTemplates()
|
$finder->findAllTemplates()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertCount(6, $templates, '->findAllTemplates() find all templates in the bundles and global folders');
|
$this->assertCount(7, $templates, '->findAllTemplates() find all templates in the bundles and global folders');
|
||||||
$this->assertContains('BaseBundle::base.format.engine', $templates);
|
$this->assertContains('BaseBundle::base.format.engine', $templates);
|
||||||
$this->assertContains('BaseBundle::this.is.a.template.format.engine', $templates);
|
$this->assertContains('BaseBundle::this.is.a.template.format.engine', $templates);
|
||||||
$this->assertContains('BaseBundle:controller:base.format.engine', $templates);
|
$this->assertContains('BaseBundle:controller:base.format.engine', $templates);
|
||||||
|
$this->assertContains('BaseBundle:controller:custom.format.engine', $templates);
|
||||||
$this->assertContains('::this.is.a.template.format.engine', $templates);
|
$this->assertContains('::this.is.a.template.format.engine', $templates);
|
||||||
$this->assertContains('::resource.format.engine', $templates);
|
$this->assertContains('::resource.format.engine', $templates);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user