collection-crud/src/Controller/PreviouslyOwnedLensesController.php

73 lines
2.0 KiB
PHP
Raw Normal View History

2017-11-30 15:06:13 -05:00
<?php
namespace App\Controller;
2017-11-30 15:06:13 -05:00
use App\Entity\PreviouslyOwnedLenses;
2017-11-30 15:06:13 -05:00
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
2018-07-11 09:18:46 -04:00
use Symfony\Component\Routing\Annotation\Route;
2017-11-30 15:06:13 -05:00
use Symfony\Component\HttpFoundation\Request;
/**
* Previouslyownedlense controller.
*
* @Route("previously-owned-lens")
*/
class PreviouslyOwnedLensesController extends Controller
{
/**
* Lists all previouslyOwnedLense entities.
*
2018-07-11 09:18:46 -04:00
* @Route("/", name="previously-owned-lens_index", methods={"GET"})
2017-11-30 15:06:13 -05:00
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$previouslyOwnedLenses = $em->getRepository(PreviouslyOwnedLenses::class)->findBy([], [
2017-11-30 15:06:13 -05:00
'brand' => 'ASC',
'productLine' => 'ASC',
'mount' => 'ASC',
'minFocalLength' => 'ASC',
'maxFStop' => 'ASC',
]);
return $this->render('previouslyownedlenses/index.html.twig', array(
'previouslyOwnedLenses' => $previouslyOwnedLenses,
));
}
/**
* Finds and displays a previouslyOwnedLense entity.
*
2018-07-11 09:18:46 -04:00
* @Route("/{id}", name="previously-owned-lens_show", methods={"GET"})
2017-11-30 15:06:13 -05:00
*/
public function showAction(PreviouslyOwnedLenses $previouslyOwnedLense)
{
return $this->render('previouslyownedlenses/show.html.twig', array(
'previouslyOwnedLense' => $previouslyOwnedLense,
));
}
/**
* Displays a form to edit an existing previouslyOwnedLense entity.
*
2018-07-11 09:18:46 -04:00
* @Route("/{id}/edit", name="previously-owned-lens_edit", methods={"GET", "POST"})
2017-11-30 15:06:13 -05:00
*/
public function editAction(Request $request, PreviouslyOwnedLenses $previouslyOwnedLense)
{
$editForm = $this->createForm('App\Form\PreviouslyOwnedLensesType', $previouslyOwnedLense);
2017-11-30 15:06:13 -05:00
$editForm->handleRequest($request);
if ($editForm->isSubmitted() && $editForm->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirectToRoute('previously-owned-lens_edit', array('id' => $previouslyOwnedLense->getId()));
}
return $this->render('previouslyownedlenses/edit.html.twig', array(
'previouslyOwnedLense' => $previouslyOwnedLense,
'edit_form' => $editForm->createView(),
));
}
}