2018-07-18 11:35:27 -04:00
|
|
|
<?php declare(strict_types=1);
|
2017-11-30 15:06:13 -05:00
|
|
|
|
2018-02-14 16:42:39 -05:00
|
|
|
namespace App\Controller;
|
2017-11-30 15:06:13 -05:00
|
|
|
|
2022-02-17 15:10:57 -05:00
|
|
|
use UnexpectedValueException;
|
|
|
|
use LogicException;
|
|
|
|
use Doctrine\ORM\ORMInvalidArgumentException;
|
2018-02-14 16:42:39 -05:00
|
|
|
use App\Entity\PreviouslyOwnedCamera;
|
|
|
|
use App\Form\PreviouslyOwnedCameraType;
|
2018-11-30 16:01:30 -05:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
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.
|
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: 'previously-owned-camera')]
|
2018-11-30 16:01:30 -05:00
|
|
|
class PreviouslyOwnedCameraController extends AbstractController
|
2017-11-30 15:06:13 -05:00
|
|
|
{
|
2018-07-16 13:10:00 -04:00
|
|
|
use FormControllerTrait;
|
|
|
|
protected const ENTITY = PreviouslyOwnedCamera::class;
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2018-07-16 13:10:00 -04:00
|
|
|
protected const FORM = PreviouslyOwnedCameraType::class;
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2017-11-30 15:06:13 -05:00
|
|
|
/**
|
|
|
|
* Lists all previouslyOwnedCamera entities.
|
|
|
|
*
|
2022-02-17 15:10:57 -05:00
|
|
|
* @throws UnexpectedValueException
|
2017-11-30 15:06:13 -05:00
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: '/', name: 'previously-owned-camera_index', methods: ['GET'])]
|
2017-11-30 15:06:13 -05:00
|
|
|
public function indexAction()
|
|
|
|
{
|
2018-07-16 13:10:00 -04:00
|
|
|
return $this->itemListView('previouslyownedcamera/index.html.twig', 'previouslyOwnedCameras', [
|
2017-11-30 15:06:13 -05:00
|
|
|
'brand' => 'ASC',
|
|
|
|
'mount' => 'ASC',
|
|
|
|
'model' => 'ASC',
|
|
|
|
]);
|
|
|
|
}
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2017-11-30 15:06:13 -05:00
|
|
|
/**
|
|
|
|
* Finds and displays a previouslyOwnedCamera entity.
|
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: '/{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
|
|
|
}
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2017-11-30 15:06:13 -05:00
|
|
|
/**
|
|
|
|
* Displays a form to edit an existing previouslyOwnedCamera entity.
|
|
|
|
*
|
2022-02-17 15:10:57 -05:00
|
|
|
* @throws LogicException
|
2017-11-30 15:06:13 -05:00
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: '/{id}/edit', name: 'previously-owned-camera_edit', methods: ['GET', 'POST'])]
|
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
|
|
|
}
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2018-02-14 15:08:03 -05:00
|
|
|
/**
|
|
|
|
* Moves a camera to the previouslyOwned table
|
|
|
|
*
|
|
|
|
* @param Request $request
|
2022-02-17 15:10:57 -05:00
|
|
|
* @throws LogicException
|
|
|
|
* @throws ORMInvalidArgumentException
|
2018-02-14 15:08:03 -05:00
|
|
|
* @return RedirectResponse
|
|
|
|
*/
|
2022-02-17 15:16:47 -05:00
|
|
|
#[Route(path: '/{id}/reacquire', name: 'previously-owned-camera_reacquire', methods: ['POST'])]
|
|
|
|
public function reacquireAction(Request $request, PreviouslyOwnedCamera $camera) : RedirectResponse
|
2018-02-14 15:08:03 -05:00
|
|
|
{
|
2018-07-16 13:50:07 -04:00
|
|
|
return $this->itemReacquire($request, $camera, 'camera_index');
|
2018-02-14 15:08:03 -05:00
|
|
|
}
|
2022-02-18 11:34:25 -05:00
|
|
|
|
2018-02-14 15:08:03 -05:00
|
|
|
/**
|
|
|
|
* Creates a form to move
|
|
|
|
*
|
|
|
|
* @param PreviouslyOwnedCamera $camera The camera entity
|
|
|
|
*/
|
|
|
|
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
|
|
|
}
|