Created
May 2, 2012 13:03
-
-
Save coreymcmahon/2576393 to your computer and use it in GitHub Desktop.
A Symfony Controller using the @template annotation - http://www.symfonycentral.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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