/** * 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 Album $album * @param string $title * @param int $position * * @return $this * * @throws InvalidAlbumInputException */ public function fromAlbum(Album $album, $title = "", $position = null) { $this->setArtist($album->getArtist()); $this->setLabel($album->getLabel()); $this->setManufacturer($album->getManufacturer()); $this->setPublisher($album->getPublisher()); $this->setReleaseDate($album->getReleaseDate()); $this->setStudio($album->getStudio()); $this->setAlbum($album); if (!empty($title)) { $this->setTitle($title); } if ($position >= 0) { $this->setTrackSequence($position); } return $this; }
/** * @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())); }