Created
April 29, 2012 11:03
-
-
Save coreymcmahon/2549428 to your computer and use it in GitHub Desktop.
Basic Symfony Controller demonstrating the use of a logical name for template - 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/BlogController.php | |
namespace MyCompany\BlogBundle\Controller; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
class BlogController extends Controller | |
{ | |
public function viewAction($id) | |
{ | |
$post = $this->get('doctrine') | |
->getEntityManager() | |
->getRepository('MyCompanyBlogBundle:Post') | |
->find($id); | |
// Use the logical name of the template | |
return $this->render('MyCompanyBlogBundle:Blog:show.html.twig', array( | |
'post' => $post, | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment