getTemplate() public method

crud.$section.$action.$entity crud.$section.$action crud.$section If nothing exists, this string is returned: "@crud/.twig"
public getTemplate ( Pimple\Container $app, string $section, string $action, string $entity ) : string
$app Pimple\Container the Silex application
$section string the section of the template, either "layout" or "template"
$action string the current calling action like "create" or "show"
$entity string the current calling entity
return string the best fitting template
Esempio n. 1
0
 public function testGetTemplate()
 {
     $app = new Application();
     $app['crud.template.list.book'] = 'testTemplateListBook.twig';
     $app['crud.template.list'] = 'testTemplateList.twig';
     $app['crud.layout.list.book'] = 'testLayoutListBook.twig';
     $app['crud.layout.list'] = 'testLayoutList.twig';
     $crudServiceProvider = new ServiceProvider();
     $read = $crudServiceProvider->getTemplate($app, 'template', 'list', 'book');
     $this->assertSame($read, $app['crud.template.list.book']);
     $read = $crudServiceProvider->getTemplate($app, 'template', 'list', 'library');
     $this->assertSame($read, $app['crud.template.list']);
     $read = $crudServiceProvider->getTemplate($app, 'layout', 'list', 'book');
     $this->assertSame($read, $app['crud.layout.list.book']);
     $read = $crudServiceProvider->getTemplate($app, 'layout', 'list', 'library');
     $this->assertSame($read, $app['crud.layout.list']);
     $expected = '@crud/list.twig';
     $read = $crudServiceProvider->getTemplate($app, 'foo', 'list', 'bar');
     $this->assertSame($read, $expected);
     $read = $crudServiceProvider->getTemplate($app, null, 'list', 'bar');
     $this->assertSame($read, $expected);
     $expected = 'testLayoutList.twig';
     $read = $crudServiceProvider->getTemplate($app, 'layout', 'list', null);
     $this->assertSame($read, $expected);
     $expected = '@crud/.twig';
     $read = $crudServiceProvider->getTemplate($app, 'layout', null, 'book');
     $this->assertSame($read, $expected);
 }