77 lines
2.1 KiB
PHP
77 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Entity\PreviouslyOwnedLenses;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
/**
|
|
* Previouslyownedlense controller.
|
|
*
|
|
* @Route("previously-owned-lens")
|
|
*/
|
|
class PreviouslyOwnedLensesController extends Controller
|
|
{
|
|
/**
|
|
* Lists all previouslyOwnedLense entities.
|
|
*
|
|
* @Route("/", name="previously-owned-lens_index")
|
|
* @Method("GET")
|
|
*/
|
|
public function indexAction()
|
|
{
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
|
$previouslyOwnedLenses = $em->getRepository('App:PreviouslyOwnedLenses')->findBy([], [
|
|
'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.
|
|
*
|
|
* @Route("/{id}", name="previously-owned-lens_show")
|
|
* @Method("GET")
|
|
*/
|
|
public function showAction(PreviouslyOwnedLenses $previouslyOwnedLense)
|
|
{
|
|
return $this->render('previouslyownedlenses/show.html.twig', array(
|
|
'previouslyOwnedLense' => $previouslyOwnedLense,
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Displays a form to edit an existing previouslyOwnedLense entity.
|
|
*
|
|
* @Route("/{id}/edit", name="previously-owned-lens_edit")
|
|
* @Method({"GET", "POST"})
|
|
*/
|
|
public function editAction(Request $request, PreviouslyOwnedLenses $previouslyOwnedLense)
|
|
{
|
|
$editForm = $this->createForm('App\Form\PreviouslyOwnedLensesType', $previouslyOwnedLense);
|
|
$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(),
|
|
));
|
|
}
|
|
}
|