2018-02-15 09:48:57 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
use App\Entity\Film;
|
|
|
|
use App\Form\FilmType;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
2018-07-11 09:18:46 -04:00
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
2018-02-15 09:48:57 -05:00
|
|
|
use Symfony\Component\Form\FormInterface;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Film controller.
|
|
|
|
*
|
|
|
|
* @Route("film")
|
|
|
|
*/
|
|
|
|
class FilmController extends Controller
|
|
|
|
{
|
2018-07-16 13:10:00 -04:00
|
|
|
use FormControllerTrait;
|
|
|
|
|
|
|
|
protected const ENTITY = Film::class;
|
|
|
|
protected const FORM = FilmType::class;
|
|
|
|
|
2018-02-15 09:48:57 -05:00
|
|
|
/**
|
|
|
|
* Lists all film entities.
|
|
|
|
*
|
2018-07-11 09:18:46 -04:00
|
|
|
* @Route("/", name="film_index", methods={"GET"})
|
2018-02-15 09:48:57 -05:00
|
|
|
*/
|
|
|
|
public function indexAction()
|
|
|
|
{
|
2018-07-16 13:10:00 -04:00
|
|
|
return $this->itemListView('film/index.html.twig', 'films', [
|
|
|
|
'rollsInCamera' => 'DESC',
|
2018-02-15 09:48:57 -05:00
|
|
|
'brand' => 'ASC',
|
|
|
|
'productLine' => 'ASC',
|
|
|
|
'filmFormat' => 'ASC',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new film entity.
|
|
|
|
*
|
2018-07-11 09:18:46 -04:00
|
|
|
* @Route("/new", name="film_new", methods={"GET", "POST"})
|
2018-02-15 09:48:57 -05:00
|
|
|
*/
|
|
|
|
public function newAction(Request $request)
|
|
|
|
{
|
2018-07-16 13:10:00 -04:00
|
|
|
return $this->itemCreate($request, 'film/new.html.twig', 'film', 'film_show');
|
2018-02-15 09:48:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds and displays a film entity.
|
|
|
|
*
|
2018-07-11 09:18:46 -04:00
|
|
|
* @Route("/{id}", name="film_show", methods={"GET"})
|
2018-02-15 09:48:57 -05:00
|
|
|
*/
|
|
|
|
public function showAction(Film $film)
|
|
|
|
{
|
2018-07-16 13:10:00 -04:00
|
|
|
return $this->itemView($film, 'film/show.html.twig', 'film');
|
2018-02-15 09:48:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a form to edit an existing film entity.
|
|
|
|
*
|
2018-07-11 09:18:46 -04:00
|
|
|
* @Route("/{id}/edit", name="film_edit", methods={"GET", "POST"})
|
2018-02-15 09:48:57 -05:00
|
|
|
* @throws \LogicException
|
|
|
|
*/
|
|
|
|
public function editAction(Request $request, Film $film)
|
|
|
|
{
|
2018-07-16 13:10:00 -04:00
|
|
|
return $this->itemUpdate($request, $film, 'film/edit.html.twig', 'film', 'film_show');
|
2018-02-15 09:48:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes a film entity.
|
|
|
|
*
|
2018-07-11 09:18:46 -04:00
|
|
|
* @Route("/{id}", name="film_delete", methods={"DELETE"})
|
2018-02-15 09:48:57 -05:00
|
|
|
* @throws \LogicException
|
|
|
|
*/
|
|
|
|
public function deleteAction(Request $request, Film $film)
|
|
|
|
{
|
2018-07-16 13:10:00 -04:00
|
|
|
return $this->itemDelete($request, $film, 'film_index');
|
2018-02-15 09:48:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a form to delete a film entity.
|
|
|
|
*
|
|
|
|
* @param Film $film The film entity
|
|
|
|
*
|
|
|
|
* @return \Symfony\Component\Form\FormInterface The form
|
|
|
|
*/
|
|
|
|
private function createDeleteForm(Film $film): FormInterface
|
|
|
|
{
|
2018-07-16 13:10:00 -04:00
|
|
|
return $this->buildForm($film, 'film_delete', 'DELETE');
|
2018-02-15 09:48:57 -05:00
|
|
|
}
|
|
|
|
}
|