Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created May 2, 2012 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymcmahon/2576393 to your computer and use it in GitHub Desktop.
Save coreymcmahon/2576393 to your computer and use it in GitHub Desktop.
A Symfony Controller using the @template annotation - http://www.symfonycentral.com
<?php
# src/MyCompany/BlogBundle/Controller/ArticleController.php
namespace MyCompany\BlogBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ArticleController extends Controller
{
/**
* @Route("/article/{id}", name="_view_article")
* @Template()
*/
public function viewAction($id)
{
$article = /* build article from model in here */;
return array('article' => $article->getBody());
/* Note: we return what would ordinarily be passed as the 2nd argument to 'render' */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment