...
Code Block | ||||
---|---|---|---|---|
| ||||
<?php namespace Acme\DemoBundle\Content; use eZ\Publish\Core\MVC\Symfony\View\ContentView; use eZ\Publish\Core\MVC\Symfony\View\Provider\Location as LocationViewProvider; use eZ\Publish\API\Repository\Values\Content\Location; class MyLocationViewProvider implements LocationViewProvider { /** * Returns a ContentView object corresponding to $location, or void if not applicable * * @param \eZ\Publish\API\Repository\Values\Content\Location $location * @param string $viewType * @return \eZ\Publish\Core\MVC\Symfony\View\ContentView|null */ public function getView( Location $location, $viewType ) { // Let's check location Id switch ( $location->id ) { // Special template for home page, passing "foo" variable to the template case 2: return new ContentView( "AcmeDemoBundle:$viewType:home.html.twig", array( 'foo' => 'bar' ) ); } // ContentType identifier (formerly "class identifier") switch ( $contentInfo$location->contentInfo->contentType->identifier ) { // For view full, it will load AcmeDemoBundle:full:small_folder.html.twig case 'folder': return new ContentView( "AcmeDemoBundle:$viewType:small_folder.html.twig" ); } } } |
...