<commit_before><?php

namespace Doshibu\AfkWatchBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Response;

use Doshibu\AfkWatchBundle\Entity\Genre;
use Doshibu\AfkWatchBundle\Entity\Image;
use Doshibu\AfkWatchBundle\Entity\Movie;
use Doshibu\AfkWatchBundle\Entity\News;
use Doshibu\AfkWatchBundle\Entity\Pays;
use Doshibu\AfkWatchBundle\Entity\Series;

class MovieController extends Controller
{
	public function indexAction(Request $request)
	{
		$movieRepo = $this->getDoctrine()
						->getManager()
						->getRepository('DoshibuAfkWatchBundle:Movie');
		$listMovie = $movieRepo->getAllWithGenres();
		$listPopular = $movieRepo->findMostPopular(35);

		return $this->render('DoshibuAfkWatchBundle:Movie:index.html.twig', array(
			'listMovie' 	=> $listMovie,
			'listPopular' 	=> $listPopular
		));
	}

	public function movieAction(Request $request, $id)
	{
		$em = $this->getDoctrine()->getManager();
		$movieRepo = $em->getRepository('DoshibuAfkWatchBundle:Movie');

		$movie = $movieRepo->findOneBy(array('id' => $id)); // joined full with genre & pays
		$movieGenders = $movie->getGenders();
		$listPopular = $movieRepo->findMostPopularByGenres($movieGenders);

		$listProposedByGenre = $movieRepo->findMostPopularByGenre($movieGenders->first()->getSlug(), 3);
		$listProposedByPays = $movieRepo->findMostPopularByPays($movie->getCountries()->first()->getSlug(), 3);

		return $this->render('DoshibuAfkWatchBundle:Movie:movie.html.twig', array(
			'movie' 				=> $movie,
			'movieGenders'			=> $movieGenders,
			'listProposedByGenre' 	=> $listProposedByGenre,
			'listProposedByPays' 	=> $listProposedByPays,
			'listPopular' 			=> $listPopular
		));
	}

	public function genreAction(Request $request, $slug, $page=1)
	{
		$em = $this->getDoctrine()->getManager();
		$movieRepo = $em->getRepository('DoshibuAfkWatchBundle:Movie');
		$genreRepo = $em->getRepository('DoshibuAfkWatchBundle:Genre');

		$genre = $genreRepo->findOneBy(array('slug' => $slug));
		if($genre === null)
		{
			throw $this->createNotFoundException('Le genre demandé n\'existe pas.');
		}

		$nbPerPage = 24;
		$listMovie = $movieRepo->findByGenre($slug, $page, $nbPerPage);
		$nbPages = ceil(count($listMovie)/$nbPerPage);
		if ( $page > $nbPages )
		{
			throw $this->createNotFoundException('La page '. $page .' n\'existe pas.');
		}

		$listPopular = $movieRepo->findMostPopularByGenre($slug);

		return $this->render('DoshibuAfkWatchBundle:Movie:genre.html.twig', array(
			'genre'			=> $genre,
			'listMovie' 	=> $listMovie,
			'nbPages'		=> $nbPages,
			'page' 			=> $page,
			'listPopular'	=> $listPopular
		));
	}

	public function paysAction(Request $request, $slug, $page=1)
	{
		$em = $this->getDoctrine()->getManager();
		$movieRepo = $em->getRepository('DoshibuAfkWatchBundle:Movie');
		$paysRepo = $em->getRepository('DoshibuAfkWatchBundle:Pays');

		$pays = $paysRepo->findOneBy(array('slug' => $slug));
		if($pays === null)
		{
			throw $this->createNotFoundException('Le pays demandé n\'existe pas.');
		}

		$nbPerPage = 24;
		$listMovie = $movieRepo->findByPays($slug, $page, $nbPerPage);
		$nbPages = ceil(count($listMovie)/$nbPerPage);
		if ( $page > $nbPages )
		{
			throw $this->createNotFoundException('La page '. $page .' n\'existe pas.');
		}

		$listPopular = $movieRepo->findMostPopularByPays($slug);

		return $this->render('DoshibuAfkWatchBundle:Movie:pays.html.twig', array(
			'pays'			=> $pays,
			'listMovie' 	=> $listMovie,
			'nbPages'		=> $nbPages,
			'page' 			=> $page,
			'listPopular'	=> $listPopular
		));
	}

	public function seriesAction(Request $request)
	{
		$em = $this->getDoctrine()->getManager();
		$serieRepo = $em->getRepository('DoshibuAfkWatchBundle:Serie');

		$listPopular = $serieRepo->findMostPopular();
		$listRated = $serieRepo->findMostRated();
		$listRecent = $serieRepo->findMostRecent();

		return $this->render('DoshibuAfkWatchBundle:Movie:series.html.twig', array(
			'listPopular'	=> $listPopular,
			'listRated'		=> $listRated,
			'listRecent' 	=> $listRecent
		));
	}

	public function serieAction(Request $request, $id)
	{
		$em = $this->getDoctrine()->getManager();
		$serieRepo = $em->getRepository('DoshibuAfkWatchBundle:Serie');

		$serie = $serieRepo->findOneBy(array('id' => $id)); // joined full with genre & pays
		$serieGenders = $serie->getGenders();
		$listPopular = $serieRepo->findMostPopularByGenres($serieGenders);

		$listProposedByGenre = $serieRepo->findMostPopularByGenre($serieGenders->first()->getSlug(), 3);
		$listProposedByPays = $serieRepo->findMostPopularByPays($serie->getCountries()->first()->getSlug(), 3);

		return $this->render('DoshibuAfkWatchBundle:Movie:serie.html.twig', array(
			'serie' 				=> $serie,
			'serieGenders'			=> $serieGenders,
			'listProposedByGenre' 	=> $listProposedByGenre,
			'listProposedByPays' 	=> $listProposedByPays,
			'listPopular' 			=> $listPopular
		));
	}

	public function newsAction(Request $request)
	{
		return $this->render('DoshibuAfkWatchBundle:Movie:news.html.twig');
	}

	public function newsSingleAction(Request $request)
	{
		return $this->render('DoshibuAfkWatchBundle:Movie:newsSingle.html.twig');
	}<commit_msg>Update notFoundException<commit_after><?php

namespace Doshibu\AfkWatchBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Response;

use Doshibu\AfkWatchBundle\Entity\Genre;
use Doshibu\AfkWatchBundle\Entity\Image;
use Doshibu\AfkWatchBundle\Entity\Movie;
use Doshibu\AfkWatchBundle\Entity\News;
use Doshibu\AfkWatchBundle\Entity\Pays;
use Doshibu\AfkWatchBundle\Entity\Series;

class MovieController extends Controller
{
	public function indexAction(Request $request)
	{
		$movieRepo = $this->getDoctrine()
						->getManager()
						->getRepository('DoshibuAfkWatchBundle:Movie');
		$listMovie = $movieRepo->getAllWithGenres();
		$listPopular = $movieRepo->findMostPopular(35);

		return $this->render('DoshibuAfkWatchBundle:Movie:index.html.twig', array(
			'listMovie' 	=> $listMovie,
			'listPopular' 	=> $listPopular
		));
	}

	public function movieAction(Request $request, $id)
	{
		$em = $this->getDoctrine()->getManager();
		$movieRepo = $em->getRepository('DoshibuAfkWatchBundle:Movie');

		$movie = $movieRepo->findOneBy(array('id' => $id)); // joined full with genre & pays
		if($movie === null)
		{
			throw $this->createNotFoundException('Ce film n\'existe pas ou plus.');
		}

		$movieGenders = $movie->getGenders();
		$listPopular = $movieRepo->findMostPopularByGenres($movieGenders);

		$listProposedByGenre = $movieRepo->findMostPopularByGenre($movieGenders->first()->getSlug(), 3);
		$listProposedByPays = $movieRepo->findMostPopularByPays($movie->getCountries()->first()->getSlug(), 3);

		return $this->render('DoshibuAfkWatchBundle:Movie:movie.html.twig', array(
			'movie' 				=> $movie,
			'movieGenders'			=> $movieGenders,
			'listProposedByGenre' 	=> $listProposedByGenre,
			'listProposedByPays' 	=> $listProposedByPays,
			'listPopular' 			=> $listPopular
		));
	}

	public function genreAction(Request $request, $slug, $page=1)
	{
		$em = $this->getDoctrine()->getManager();
		$movieRepo = $em->getRepository('DoshibuAfkWatchBundle:Movie');
		$genreRepo = $em->getRepository('DoshibuAfkWatchBundle:Genre');

		$genre = $genreRepo->findOneBy(array('slug' => $slug));
		if($genre === null)
		{
			throw $this->createNotFoundException('Le genre demandé n\'existe pas.');
		}

		$nbPerPage = 24;
		$listMovie = $movieRepo->findByGenre($slug, $page, $nbPerPage);
		$nbPages = ceil(count($listMovie)/$nbPerPage);
		if ( $page > $nbPages )
		{
			if($page === 1)
			{
				throw $this->createNotFoundException('Malheureusement aucune donnée n\'est enregistré avec ce genre en référence.');
			}
			else
			{
				throw $this->createNotFoundException('La page '. $page .' n\'existe pas.');
			}
		}

		$listPopular = $movieRepo->findMostPopularByGenre($slug);

		return $this->render('DoshibuAfkWatchBundle:Movie:genre.html.twig', array(
			'genre'			=> $genre,
			'listMovie' 	=> $listMovie,
			'nbPages'		=> $nbPages,
			'page' 			=> $page,
			'listPopular'	=> $listPopular
		));
	}

	public function paysAction(Request $request, $slug, $page=1)
	{
		$em = $this->getDoctrine()->getManager();
		$movieRepo = $em->getRepository('DoshibuAfkWatchBundle:Movie');
		$paysRepo = $em->getRepository('DoshibuAfkWatchBundle:Pays');

		$pays = $paysRepo->findOneBy(array('slug' => $slug));
		if($pays === null)
		{
			throw $this->createNotFoundException('Le pays demandé n\'existe pas.');
		}

		$nbPerPage = 24;
		$listMovie = $movieRepo->findByPays($slug, $page, $nbPerPage);
		$nbPages = ceil(count($listMovie)/$nbPerPage);
		if ( $page > $nbPages )
		{
			if($page === 1)
			{
				throw $this->createNotFoundException('Malheureusement aucune donnée n\'est enregistré avec ce pays en référence.');
			}
			else
			{
				throw $this->createNotFoundException('La page '. $page .' n\'existe pas.');
			}
		}

		$listPopular = $movieRepo->findMostPopularByPays($slug);

		return $this->render('DoshibuAfkWatchBundle:Movie:pays.html.twig', array(
			'pays'			=> $pays,
			'listMovie' 	=> $listMovie,
			'nbPages'		=> $nbPages,
			'page' 			=> $page,
			'listPopular'	=> $listPopular
		));
	}

	public function seriesAction(Request $request)
	{
		$em = $this->getDoctrine()->getManager();
		$serieRepo = $em->getRepository('DoshibuAfkWatchBundle:Serie');

		$listPopular = $serieRepo->findMostPopular();
		$listRated = $serieRepo->findMostRated();
		$listRecent = $serieRepo->findMostRecent();

		return $this->render('DoshibuAfkWatchBundle:Movie:series.html.twig', array(
			'listPopular'	=> $listPopular,
			'listRated'		=> $listRated,
			'listRecent' 	=> $listRecent
		));
	}

	public function serieAction(Request $request, $id)
	{
		$em = $this->getDoctrine()->getManager();
		$serieRepo = $em->getRepository('DoshibuAfkWatchBundle:Serie');

		$serie = $serieRepo->findOneBy(array('id' => $id)); // joined full with genre & pays
		if($serie === null)
		{
			throw $this->createNotFoundException('Ce film n\'existe pas ou plus.');
		}

		$serieGenders = $serie->getGenders();
		$listPopular = $serieRepo->findMostPopularByGenres($serieGenders);

		$listProposedByGenre = $serieRepo->findMostPopularByGenre($serieGenders->first()->getSlug(), 3);
		$listProposedByPays = $serieRepo->findMostPopularByPays($serie->getCountries()->first()->getSlug(), 3);

		return $this->render('DoshibuAfkWatchBundle:Movie:serie.html.twig', array(
			'serie' 				=> $serie,
			'serieGenders'			=> $serieGenders,
			'listProposedByGenre' 	=> $listProposedByGenre,
			'listProposedByPays' 	=> $listProposedByPays,
			'listPopular' 			=> $listPopular
		));
	}

	public function newsAction(Request $request)
	{
		return $this->render('DoshibuAfkWatchBundle:Movie:news.html.twig');
	}

	public function newsSingleAction(Request $request)
	{
		return $this->render('DoshibuAfkWatchBundle:Movie:newsSingle.html.twig');
	}
{'fraction_non_alphanumeric': 0.16557695705955117, 'fraction_numerical': 0.002297225658243506, 'mean_word_length': 5.219230769230769, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 195, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4329994', 'n_tokens_mistral': 4567, 'n_tokens_neox': 4185, 'n_words': 593}