85 lines
2.6 KiB
PHP
85 lines
2.6 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Controller;
|
|
|
|
use UnexpectedValueException;
|
|
use LogicException;
|
|
use Doctrine\ORM\ORMInvalidArgumentException;
|
|
use App\Entity\PreviouslyOwnedCamera;
|
|
use App\Form\PreviouslyOwnedCameraType;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Symfony\Component\Form\FormInterface;
|
|
use Symfony\Component\HttpFoundation\{RedirectResponse, Request};
|
|
|
|
/**
|
|
* Previouslyownedcamera controller.
|
|
*/
|
|
#[Route(path: 'previously-owned-camera')]
|
|
class PreviouslyOwnedCameraController extends AbstractController
|
|
{
|
|
use FormControllerTrait;
|
|
protected const ENTITY = PreviouslyOwnedCamera::class;
|
|
|
|
protected const FORM = PreviouslyOwnedCameraType::class;
|
|
|
|
/**
|
|
* Lists all previouslyOwnedCamera entities.
|
|
*
|
|
* @throws UnexpectedValueException
|
|
*/
|
|
#[Route(path: '/', name: 'previously-owned-camera_index', methods: ['GET'])]
|
|
public function indexAction()
|
|
{
|
|
return $this->itemListView('previouslyownedcamera/index.html.twig', 'previouslyOwnedCameras', [
|
|
'brand' => 'ASC',
|
|
'mount' => 'ASC',
|
|
'model' => 'ASC',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Finds and displays a previouslyOwnedCamera entity.
|
|
*/
|
|
#[Route(path: '/{id}', name: 'previously-owned-camera_show', methods: ['GET'])]
|
|
public function showAction(PreviouslyOwnedCamera $previouslyOwnedCamera)
|
|
{
|
|
return $this->itemView($previouslyOwnedCamera, 'previouslyownedcamera/show.html.twig', 'previouslyOwnedCamera');
|
|
}
|
|
|
|
/**
|
|
* Displays a form to edit an existing previouslyOwnedCamera entity.
|
|
*
|
|
* @throws LogicException
|
|
*/
|
|
#[Route(path: '/{id}/edit', name: 'previously-owned-camera_edit', methods: ['GET', 'POST'])]
|
|
public function editAction(Request $request, PreviouslyOwnedCamera $previouslyOwnedCamera)
|
|
{
|
|
return $this->itemUpdate($request, $previouslyOwnedCamera, 'previouslyownedcamera/edit.html.twig', 'previouslyOwnedCamera', 'previously-owned-camera_show');
|
|
}
|
|
|
|
/**
|
|
* Moves a camera to the previouslyOwned table
|
|
*
|
|
* @param Request $request
|
|
* @throws LogicException
|
|
* @throws ORMInvalidArgumentException
|
|
* @return RedirectResponse
|
|
*/
|
|
#[Route(path: '/{id}/reacquire', name: 'previously-owned-camera_reacquire', methods: ['POST'])]
|
|
public function reacquireAction(Request $request, PreviouslyOwnedCamera $camera) : RedirectResponse
|
|
{
|
|
return $this->itemReacquire($request, $camera, 'camera_index');
|
|
}
|
|
|
|
/**
|
|
* Creates a form to move
|
|
*
|
|
* @param PreviouslyOwnedCamera $camera The camera entity
|
|
*/
|
|
private function createReacquireForm(PreviouslyOwnedCamera $camera): FormInterface
|
|
{
|
|
return $this->buildForm($camera, 'previously-owned-camera_reacquire', 'POST');
|
|
}
|
|
}
|