94 lines
3.0 KiB
PHP
94 lines
3.0 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Entity\PreviouslyOwnedCamera;
|
|
use App\Form\PreviouslyOwnedCameraType;
|
|
use App\Traits\FormControllerTrait;
|
|
use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException};
|
|
use LogicException;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\Form\FormInterface;
|
|
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use UnexpectedValueException;
|
|
|
|
/**
|
|
* Previouslyownedcamera controller.
|
|
*/
|
|
#[Route(path: 'previously-owned-camera')]
|
|
class PreviouslyOwnedCameraController extends AbstractController
|
|
{
|
|
use FormControllerTrait;
|
|
|
|
protected const ENTITY = PreviouslyOwnedCamera::class;
|
|
protected const TEMPLATE_PATH = 'previouslyownedcamera/';
|
|
protected const ROUTE_PREFIX = 'previously-owned-camera_';
|
|
protected const FORM = PreviouslyOwnedCameraType::class;
|
|
|
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Lists all previouslyOwnedCamera entities.
|
|
*
|
|
* @throws UnexpectedValueException
|
|
*/
|
|
#[Route(path: '/', name: 'previously-owned-camera_index', methods: ['GET'])]
|
|
public function indexAction(): Response
|
|
{
|
|
return $this->itemListView('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): Response
|
|
{
|
|
return $this->itemView($previouslyOwnedCamera, '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): RedirectResponse|Response
|
|
{
|
|
return $this->itemUpdate($request, $previouslyOwnedCamera, 'previouslyOwnedCamera');
|
|
}
|
|
|
|
/**
|
|
* 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');
|
|
}
|
|
}
|