/**
* @Route("/{slug}.html", name="song_show")
* @Template()
*/
public function showAction($slug)
{
$em = $this->getDoctrine()->getEntityManager();
$entity = $em->getRepository('MyFrontendBundle:Song')->findOneBySlug($slug);
if (!$entity) {
throw $this->createNotFoundException('Podana strona nie istnieje!');
}
return array('entity' => $entity);
}
Listing 27.2. Kod akcji show
Rozdział 27. Identyfikacja rekordu na podstawie wartości slug