コード例 #1
0
 /**
  * Retrieves media with id $id or throws an exception if not found.
  *
  * @param int $id
  *
  * @return MediaInterface
  *
  * @throws AccessDeniedException
  * @throws NotFoundHttpException
  */
 protected function getMedium($id = null)
 {
     $media = $this->mediaManager->findOneBy(array('id' => $id));
     if (null === $media) {
         throw new NotFoundHttpException(sprintf('Media (%d) was not found', $id));
     }
     return $media;
 }
コード例 #2
0
 /**
  * @throws NotFoundHttpException
  *
  * @param string $id
  *
  * @return MediaInterface
  */
 private function getMedia($id)
 {
     $media = $this->mediaManager->findOneBy(array('id' => $id));
     if (!$media) {
         throw new NotFoundHttpException('Media not found');
     }
     return $media;
 }