http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/view.html
The
@Template annotation associates a controller with a template name:1 2 3 4 5 6 7 8 9 10 11 12 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
/**
* @Template("SensioBlogBundle:Post:show")
*/
public function showAction($id)
{
// get the Post
$post = ...;
return array('post' => $post);
}
|
@Template annotation, the controller should return an
array of parameters to pass to the view instead of a Response objectIf the action returns a
Response object, the @Template
annotation is simply ignored If the template is named after the controller and action names, which is the case for the above example, you can even omit the annotation value:
1 2 3 4 5 6 7 8 9 10 | /**
* @Template
*/
public function showAction($id)
{
// get the Post
$post = ...;
return array('post' => $post);
}
|
沒有留言:
張貼留言