/**
  * Test an empty Genre entity
  */
 public function testEmptyGenre()
 {
     $genre = new Genre();
     $this->assertNull($genre->getId());
     $this->assertNull($genre->getName());
     $this->assertNull($genre->getCreatedBy());
     $this->assertNull($genre->getUpdatedBy());
     $this->assertNull($genre->getSlug());
 }
 /**
  * @Route("/{_locale}/{page}", name="app_index", requirements={"page": "\d+", "_locale": "%locales%"}, defaults={"page": 1, "_locale": "%locale%"})
  * @Route("/{_locale}/by/genre/{genre}/{page}", name="app_index_genre", requirements={"page": "\d+", "_locale": "%locales%"}, defaults={"page": 1, "_locale": "%locale%"})
  * @Method("GET")
  * @ParamConverter("genre", class="AppBundle:Genre", options={
  *    "repository_method" = "findOneBySlug",
  *    "mapping": {"genre": "slug", "_locale": "locale"},
  *    "map_method_signature" = true
  * })
  * @Template("AppBundle:Index:index.html.twig")
  * @param null|Genre $genre
  * @param int $page
  * @return array
  */
 public function popularAction(Genre $genre = null, $page = 1, $_route)
 {
     if ($_route === 'app_index_genre' && $genre === null) {
         throw $this->createNotFoundException('Genre does not exist');
     }
     /** @var \ArrayIterator $audios */
     $audios = $this->get('vk')->getPopularAudios($genre ? $genre->getId() : null);
     return ['current_page' => $page, 'genre' => $genre, 'audios_on_page' => self::AUDIOS_ON_PAGE, 'page_count' => round($audios->count() / self::AUDIOS_ON_PAGE), 'audios' => new \LimitIterator($audios, ($page - 1) * self::AUDIOS_ON_PAGE, self::AUDIOS_ON_PAGE)];
 }
Example #3
0
 /**
  * Creates a form to delete a Genre entity.
  *
  * @param Genre $genre The Genre entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Genre $genre)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('genre_delete', array('id' => $genre->getId())))->setMethod('DELETE')->getForm();
 }