100 lines
3.2 KiB
PHP
100 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace CameraBundle\Controller;
|
|
|
|
use CameraBundle\Entity\PreviouslyOwnedFlash;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
/**
|
|
* Previouslyownedflash controller.
|
|
*
|
|
* @Route("previously-owned-flash")
|
|
*/
|
|
class PreviouslyOwnedFlashController extends Controller
|
|
{
|
|
/**
|
|
* Lists all previouslyOwnedFlash entities.
|
|
*
|
|
* @Route("/", name="previously-owned-flash_index")
|
|
* @Method("GET")
|
|
*/
|
|
public function indexAction()
|
|
{
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
|
$previouslyOwnedFlashes = $em->getRepository('CameraBundle:PreviouslyOwnedFlash')->findBy([], [
|
|
'brand' => 'ASC',
|
|
'model' => 'ASC'
|
|
]);
|
|
|
|
return $this->render('previouslyownedflash/index.html.twig', array(
|
|
'previouslyOwnedFlashes' => $previouslyOwnedFlashes,
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Creates a new previouslyOwnedFlash entity.
|
|
*
|
|
* @Route("/new", name="previously-owned-flash_new")
|
|
* @Method({"GET", "POST"})
|
|
*/
|
|
public function newAction(Request $request)
|
|
{
|
|
$previouslyOwnedFlash = new Previouslyownedflash();
|
|
$form = $this->createForm('CameraBundle\Form\PreviouslyOwnedFlashType', $previouslyOwnedFlash);
|
|
$form->handleRequest($request);
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
$em = $this->getDoctrine()->getManager();
|
|
$em->persist($previouslyOwnedFlash);
|
|
$em->flush();
|
|
|
|
return $this->redirectToRoute('previously-owned-flash_show', array('id' => $previouslyOwnedFlash->getId()));
|
|
}
|
|
|
|
return $this->render('previouslyownedflash/new.html.twig', array(
|
|
'previouslyOwnedFlash' => $previouslyOwnedFlash,
|
|
'form' => $form->createView(),
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Finds and displays a previouslyOwnedFlash entity.
|
|
*
|
|
* @Route("/{id}", name="previously-owned-flash_show")
|
|
* @Method("GET")
|
|
*/
|
|
public function showAction(PreviouslyOwnedFlash $previouslyOwnedFlash)
|
|
{
|
|
return $this->render('previouslyownedflash/show.html.twig', array(
|
|
'previouslyOwnedFlash' => $previouslyOwnedFlash
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Displays a form to edit an existing previouslyOwnedFlash entity.
|
|
*
|
|
* @Route("/{id}/edit", name="previously-owned-flash_edit")
|
|
* @Method({"GET", "POST"})
|
|
*/
|
|
public function editAction(Request $request, PreviouslyOwnedFlash $previouslyOwnedFlash)
|
|
{
|
|
$editForm = $this->createForm('CameraBundle\Form\PreviouslyOwnedFlashType', $previouslyOwnedFlash);
|
|
$editForm->handleRequest($request);
|
|
|
|
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
|
$this->getDoctrine()->getManager()->flush();
|
|
|
|
return $this->redirectToRoute('previously-owned-flash_edit', array('id' => $previouslyOwnedFlash->getId()));
|
|
}
|
|
|
|
return $this->render('previouslyownedflash/edit.html.twig', array(
|
|
'previouslyOwnedFlash' => $previouslyOwnedFlash,
|
|
'edit_form' => $editForm->createView(),
|
|
));
|
|
}
|
|
}
|