2017-11-30 15:06:13 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace CameraBundle\Controller;
|
|
|
|
|
|
|
|
use CameraBundle\Entity\PreviouslyOwnedCamera;
|
2018-01-04 10:42:36 -05:00
|
|
|
use CameraBundle\Form\PreviouslyOwnedCameraType;
|
2017-11-30 15:06:13 -05:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Previouslyownedcamera controller.
|
|
|
|
*
|
|
|
|
* @Route("previously-owned-camera")
|
|
|
|
*/
|
|
|
|
class PreviouslyOwnedCameraController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Lists all previouslyOwnedCamera entities.
|
|
|
|
*
|
|
|
|
* @Route("/", name="previously-owned-camera_index")
|
|
|
|
* @Method("GET")
|
2018-01-04 10:42:36 -05:00
|
|
|
* @throws \UnexpectedValueException
|
2017-11-30 15:06:13 -05:00
|
|
|
*/
|
|
|
|
public function indexAction()
|
|
|
|
{
|
|
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
|
|
|
|
|
$previouslyOwnedCameras = $em->getRepository('CameraBundle:PreviouslyOwnedCamera')->findBy([], [
|
|
|
|
'brand' => 'ASC',
|
|
|
|
'mount' => 'ASC',
|
|
|
|
'model' => 'ASC',
|
|
|
|
]);
|
|
|
|
|
|
|
|
return $this->render('previouslyownedcamera/index.html.twig', array(
|
|
|
|
'previouslyOwnedCameras' => $previouslyOwnedCameras,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds and displays a previouslyOwnedCamera entity.
|
|
|
|
*
|
|
|
|
* @Route("/{id}", name="previously-owned-camera_show")
|
|
|
|
* @Method("GET")
|
|
|
|
*/
|
|
|
|
public function showAction(PreviouslyOwnedCamera $previouslyOwnedCamera)
|
|
|
|
{
|
|
|
|
return $this->render('previouslyownedcamera/show.html.twig', array(
|
|
|
|
'previouslyOwnedCamera' => $previouslyOwnedCamera,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays a form to edit an existing previouslyOwnedCamera entity.
|
|
|
|
*
|
|
|
|
* @Route("/{id}/edit", name="previously-owned-camera_edit")
|
|
|
|
* @Method({"GET", "POST"})
|
2018-01-04 10:42:36 -05:00
|
|
|
* @throws \LogicException
|
2017-11-30 15:06:13 -05:00
|
|
|
*/
|
|
|
|
public function editAction(Request $request, PreviouslyOwnedCamera $previouslyOwnedCamera)
|
|
|
|
{
|
2018-01-04 10:42:36 -05:00
|
|
|
$editForm = $this->createForm(PreviouslyOwnedCameraType::class, $previouslyOwnedCamera);
|
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-camera_edit', array('id' => $previouslyOwnedCamera->getId()));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->render('previouslyownedcamera/edit.html.twig', array(
|
|
|
|
'previouslyOwnedCamera' => $previouslyOwnedCamera,
|
|
|
|
'edit_form' => $editForm->createView(),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|