collection-crud/src/Controller/PreviouslyOwnedCameraContro...

88 lines
2.5 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\PreviouslyOwnedCamera;
use App\Form\PreviouslyOwnedCameraType;
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;
2018-02-14 15:08:03 -05:00
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request};
2017-11-30 15:06:13 -05:00
/**
* Previouslyownedcamera controller.
*
* @Route("previously-owned-camera")
*/
class PreviouslyOwnedCameraController extends Controller
{
use FormControllerTrait;
protected const ENTITY = PreviouslyOwnedCamera::class;
protected const FORM = PreviouslyOwnedCameraType::class;
2017-11-30 15:06:13 -05:00
/**
* Lists all previouslyOwnedCamera entities.
*
2018-07-11 09:18:46 -04:00
* @Route("/", name="previously-owned-camera_index", methods={"GET"})
2018-01-04 10:42:36 -05:00
* @throws \UnexpectedValueException
2017-11-30 15:06:13 -05:00
*/
public function indexAction()
{
return $this->itemListView('previouslyownedcamera/index.html.twig', 'previouslyOwnedCameras', [
2017-11-30 15:06:13 -05:00
'brand' => 'ASC',
'mount' => 'ASC',
'model' => 'ASC',
]);
}
/**
* Finds and displays a previouslyOwnedCamera entity.
*
2018-07-11 09:18:46 -04:00
* @Route("/{id}", name="previously-owned-camera_show", methods={"GET"})
2017-11-30 15:06:13 -05:00
*/
public function showAction(PreviouslyOwnedCamera $previouslyOwnedCamera)
{
2018-07-16 13:50:07 -04:00
return $this->itemView($previouslyOwnedCamera, 'previouslyownedcamera/show.html.twig', 'previouslyOwnedCamera');
2017-11-30 15:06:13 -05:00
}
/**
* Displays a form to edit an existing previouslyOwnedCamera entity.
*
2018-07-11 09:18:46 -04:00
* @Route("/{id}/edit", name="previously-owned-camera_edit", methods={"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-07-16 13:50:07 -04:00
return $this->itemUpdate($request, $previouslyOwnedCamera, 'previouslyownedcamera/edit.html.twig', 'previouslyOwnedCamera', 'previously-owned-camera_show');
2017-11-30 15:06:13 -05:00
}
2018-02-14 15:08:03 -05:00
/**
* Moves a camera to the previouslyOwned table
*
2018-07-11 09:18:46 -04:00
* @Route("/{id}/reacquire", name="previously-owned-camera_reacquire", methods={"POST"})
2018-02-14 15:08:03 -05:00
* @param Request $request
* @param PreviouslyOwnedCamera $camera
* @throws \LogicException
* @throws \Doctrine\ORM\ORMInvalidArgumentException
* @return RedirectResponse
*/
public function reacquireAction(Request $request, PreviouslyOwnedCamera $camera): RedirectResponse
{
2018-07-16 13:50:07 -04:00
return $this->itemReacquire($request, $camera, 'camera_index');
2018-02-14 15:08:03 -05:00
}
/**
* Creates a form to move
*
* @param PreviouslyOwnedCamera $camera The camera entity
*
* @return FormInterface
*/
private function createReacquireForm(PreviouslyOwnedCamera $camera): FormInterface
{
2018-07-16 13:50:07 -04:00
return $this->buildForm($camera, 'previously-owned-camera_reacquire', 'POST');
2018-02-14 15:08:03 -05:00
}
2017-11-30 15:06:13 -05:00
}