/** * Show album from its id */ public function showAction(Album $album) { //$album = $this->getDoctrine()->getRepository('ProgramBundle:Album')->findPublishedBySlug($slug); if (!$album) { throw $this->createNotFoundException('L’album est introuvable.'); } // hide content if not published and user not logged if (!$album->getPublished() && !$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED')) { throw $this->createNotFoundException('L’album est indisponible.'); } if ($seoPage = $this->get('sonata.seo.page')) { $seoPage->addTitle(sprintf('%s - %s', $album->getArtist(), $album->getTitle()))->addMeta('name', 'description', $album->getResume())->addMeta('property', 'og:title', sprintf('%s - %s', $album->getArtist(), $album->getTitle()))->addMeta('property', 'og:type', 'article')->addMeta('property', 'og:url', $this->generateUrl('album', array('slug' => $album->getSlug()), true))->addMeta('property', 'og:description', $album->getResume()); } $breadcrumbs = $this->get("white_october_breadcrumbs"); $breadcrumbs->addItem('Musique'); $breadcrumbs->addRouteItem('L’album de la semaine', 'albums'); $breadcrumbs->addItem($album->getArtist() . ' - ' . $album->getTitle()); return $this->render('ProgramBundle:Album:show.html.twig', compact('album')); }
/** * @param AlbumModel $album * * @return AlbumModel */ public function albumExistsYet(AlbumModel $album) { $result = null; if (!isset($this->entityManager)) { $this->setUp(); } return $this->entityManager->getRepository("ProgramBundle:Album")->findOneBy(array('title' => $album->getTitle(), 'artist' => $album->getArtist())); }