Convert other PHPDoc annotations to PHP attributes

This commit is contained in:
Timothy Warren 2022-02-17 15:16:47 -05:00
parent dbfe26e27b
commit 372d348b16
10 changed files with 54 additions and 161 deletions

View File

@ -15,25 +15,20 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Camera controller.
*
* @Route("camera")
*/
#[Route(path: 'camera')]
class CameraController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = Camera::class;
protected const FORM = CameraType::class;
/**
* Lists all camera entities.
*
* @Route("/", name="camera_index", methods={"GET"})
*/
#[Route(path: '/', name: 'camera_index', methods: ['GET'])]
public function indexAction() : Response
{
$em = $this->getDoctrine()->getManager();
$receivedItems = $em->getRepository(self::ENTITY)->findBy([
'received' => true
], [
@ -49,74 +44,64 @@ class CameraController extends AbstractController
'mount' => 'ASC',
'model' => 'ASC',
]);
$working = array_filter($receivedItems, [$this, 'isWorking']);
$notWorking = array_filter($receivedItems, [$this, 'isNotWorking']);
return $this->render('camera/index.html.twig', [
'not_received' => $newItems,
'not_working' => $notWorking,
'working' => $working,
]);
}
/**
* Creates a new camera entity.
*
* @Route("/new", name="camera_new", methods={"GET", "POST"})
*/
#[Route(path: '/new', name: 'camera_new', methods: ['GET', 'POST'])]
public function newAction(Request $request)
{
return $this->itemCreate($request, 'camera/new.html.twig', 'camera', 'camera_show');
}
/**
* Finds and displays a camera entity.
*
* @Route("/{id}", name="camera_show", methods={"GET"})
*/
#[Route(path: '/{id}', name: 'camera_show', methods: ['GET'])]
public function showAction(Camera $camera)
{
return $this->itemView($camera, 'camera/show.html.twig', 'camera');
}
/**
* Displays a form to edit an existing camera entity.
*
* @Route("/{id}/edit", name="camera_edit", methods={"GET", "POST"})
* @throws LogicException
*/
#[Route(path: '/{id}/edit', name: 'camera_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, Camera $camera)
{
return $this->itemUpdate($request, $camera, 'camera/edit.html.twig', 'camera', 'camera_show');
}
/**
* Deletes a camera entity.
*
* @Route("/{id}", name="camera_delete", methods={"DELETE"})
* @throws LogicException
*/
#[Route(path: '/{id}', name: 'camera_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, Camera $camera) : RedirectResponse
{
return $this->itemDelete($request, $camera, 'camera_index');
}
/**
* Moves a camera to the previouslyOwned table
*
* @Route("/{id}/deacquire", name="camera_deacquire", methods={"POST"})
* @param Request $request
* @param Camera $camera
* @throws LogicException
* @throws ORMInvalidArgumentException
* @return RedirectResponse
*/
#[Route(path: '/{id}/deacquire', name: 'camera_deacquire', methods: ['POST'])]
public function deacquireAction(Request $request, Camera $camera) : RedirectResponse
{
return $this->itemDeacquire($request, $camera, 'previously-owned-camera_index');
}
/**
* Creates a form to delete a camera entity.
*
@ -128,7 +113,6 @@ class CameraController extends AbstractController
{
return $this->buildForm($camera, 'camera_delete', 'DELETE');
}
/**
* Creates a form to move
*
@ -140,12 +124,10 @@ class CameraController extends AbstractController
{
return $this->buildForm($camera, 'camera_deacquire');
}
private function isWorking(Camera $camera): bool
{
return $camera->getIsWorking();
}
private function isNotWorking(Camera $camera): bool
{
return !$this->isWorking($camera);

View File

@ -11,68 +11,55 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Cameratype controller.
*
* @Route("camera-type")
*/
#[Route(path: 'camera-type')]
class CameraTypeController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = CameraType::class;
protected const FORM = CameraTypeType::class;
/**
* Lists all cameraType entities.
*
* @Route("/", name="camera-type_index", methods={"GET"})
*/
#[Route(path: '/', name: 'camera-type_index', methods: ['GET'])]
public function indexAction()
{
return $this->itemListView('cameratype/index.html.twig', 'cameraTypes', [
'type' => 'ASC',
]);
}
/**
* Creates a new cameraType entity.
*
* @Route("/new", name="camera-type_new", methods={"GET", "POST"})
*/
#[Route(path: '/new', name: 'camera-type_new', methods: ['GET', 'POST'])]
public function newAction(Request $request)
{
return $this->itemCreate($request, 'cameratype/new.html.twig', 'cameraType', 'camera-type_show');
}
/**
* Finds and displays a cameraType entity.
*
* @Route("/{id}", name="camera-type_show", methods={"GET"})
*/
#[Route(path: '/{id}', name: 'camera-type_show', methods: ['GET'])]
public function showAction(CameraType $cameraType)
{
return $this->itemView($cameraType, 'cameratype/show.html.twig', 'cameraType');
}
/**
* Displays a form to edit an existing cameraType entity.
*
* @Route("/{id}/edit", name="camera-type_edit", methods={"GET", "POST"})
*/
#[Route(path: '/{id}/edit', name: 'camera-type_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, CameraType $cameraType)
{
return $this->itemUpdate($request, $cameraType, 'cameratype/edit.html.twig', 'cameraType', 'camera-type_show');
}
/**
* Deletes a cameraType entity.
*
* @Route("/{id}", name="camera-type_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'camera-type_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, CameraType $cameraType)
{
return $this->itemDelete($request, $cameraType, 'camera-type_index');
}
/**
* Creates a form to delete a cameraType entity.
*

View File

@ -9,9 +9,7 @@ use Symfony\Component\HttpFoundation\Request;
class DefaultController extends AbstractController
{
/**
* @Route("/", name="homepage")
*/
#[Route(path: '/', name: 'homepage')]
public function indexAction(Request $request) : Response
{
// replace this example code with whatever you need

View File

@ -14,26 +14,20 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Film controller.
*
* @Route("film")
*/
#[Route(path: 'film')]
class FilmController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = Film::class;
protected const FORM = FilmType::class;
/**
* Lists all film entities.
*
* @Route("/", name="film_index", methods={"GET"})
*/
#[Route(path: '/', name: 'film_index', methods: ['GET'])]
public function indexAction() : Response
{
$repo = $this->getDoctrine()->getManager()->getRepository(self::ENTITY);
$criteria = Criteria::create()
->where(Criteria::expr()->gt('rollsInCamera', 0))
->orderBy([
@ -42,9 +36,7 @@ class FilmController extends AbstractController
'rollsInCamera' => Criteria::DESC,
'productLine' => Criteria::ASC,
]);
$inCamera = $repo->matching($criteria);
$notInCamera = $repo->findBy([
'rollsInCamera' => 0,
], [
@ -52,55 +44,47 @@ class FilmController extends AbstractController
'productLine' => 'ASC',
'filmFormat' => 'ASC',
]);
return $this->render('film/index.html.twig', [
'in_camera' => $inCamera,
'films' => $notInCamera,
]);
}
/**
* Creates a new film entity.
*
* @Route("/new", name="film_new", methods={"GET", "POST"})
*/
#[Route(path: '/new', name: 'film_new', methods: ['GET', 'POST'])]
public function newAction(Request $request)
{
return $this->itemCreate($request, 'film/new.html.twig', 'film', 'film_show');
}
/**
* Finds and displays a film entity.
*
* @Route("/{id}", name="film_show", methods={"GET"})
*/
#[Route(path: '/{id}', name: 'film_show', methods: ['GET'])]
public function showAction(Film $film)
{
return $this->itemView($film, 'film/show.html.twig', 'film');
}
/**
* Displays a form to edit an existing film entity.
*
* @Route("/{id}/edit", name="film_edit", methods={"GET", "POST"})
* @throws LogicException
*/
#[Route(path: '/{id}/edit', name: 'film_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, Film $film)
{
return $this->itemUpdate($request, $film, 'film/edit.html.twig', 'film', 'film_show');
}
/**
* Deletes a film entity.
*
* @Route("/{id}", name="film_delete", methods={"DELETE"})
* @throws LogicException
*/
#[Route(path: '/{id}', name: 'film_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, Film $film)
{
return $this->itemDelete($request, $film, 'film_index');
}
/**
* Creates a form to delete a film entity.
*

View File

@ -11,66 +11,53 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Flash controller.
*
* @Route("flash")
*/
#[Route(path: 'flash')]
class FlashController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = Flash::class;
protected const FORM = FlashType::class;
/**
* Lists all flash entities.
*
* @Route("/", name="flash_index", methods={"GET"})
*/
#[Route(path: '/', name: 'flash_index', methods: ['GET'])]
public function indexAction()
{
return $this->itemListView('flash/index.html.twig', 'flashes');
}
/**
* Creates a new flash entity.
*
* @Route("/new", name="flash_new", methods={"GET", "POST"})
*/
#[Route(path: '/new', name: 'flash_new', methods: ['GET', 'POST'])]
public function newAction(Request $request)
{
return $this->itemCreate($request, 'flash/new.html.twig', 'flash', 'flash_show');
}
/**
* Finds and displays a flash entity.
*
* @Route("/{id}", name="flash_show", methods={"GET"})
*/
#[Route(path: '/{id}', name: 'flash_show', methods: ['GET'])]
public function showAction(Flash $flash)
{
return $this->itemView($flash, 'flash/show.html.twig', 'flash');
}
/**
* Displays a form to edit an existing flash entity.
*
* @Route("/{id}/edit", name="flash_edit", methods={"GET", "POST"})
*/
#[Route(path: '/{id}/edit', name: 'flash_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, Flash $flash)
{
return $this->itemUpdate($request, $flash, 'flash/edit.html.twig', 'flash', 'flash_show');
}
/**
* Deletes a flash entity.
*
* @Route("/{id}", name="flash_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'flash_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, Flash $flash)
{
return $this->itemDelete($request, $flash, 'flash_index');
}
/**
* Creates a form to delete a flash entity.
*

View File

@ -11,25 +11,20 @@ use Symfony\Component\HttpFoundation\{Request, RedirectResponse};
/**
* Lens controller.
*
* @Route("lens")
*/
#[Route(path: 'lens')]
class LensesController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = Lenses::class;
protected const FORM = LensesType::class;
/**
* Lists all lens entities.
*
* @Route("/", name="lens_index", methods={"GET"})
*/
#[Route(path: '/', name: 'lens_index', methods: ['GET'])]
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$receivedItems = $em->getRepository(self::ENTITY)->findBy([
'received' => true
], [
@ -48,66 +43,55 @@ class LensesController extends AbstractController
'minFocalLength' => 'ASC',
'maxFStop' => 'ASC',
]);
return $this->render('lenses/index.html.twig', [
'not_received' => $newItems,
'lenses' => $receivedItems,
]);
}
/**
* Creates a new lens entity.
*
* @Route("/new", name="lens_new", methods={"GET", "POST"})
*/
#[Route(path: '/new', name: 'lens_new', methods: ['GET', 'POST'])]
public function newAction(Request $request)
{
return $this->itemCreate($request, 'lenses/new.html.twig', 'lense', 'lens_show');
}
/**
* Finds and displays a lens entity.
*
* @Route("/{id}", name="lens_show", methods={"GET"})
*/
#[Route(path: '/{id}', name: 'lens_show', methods: ['GET'])]
public function showAction(Lenses $lens)
{
return $this->itemView($lens, 'lenses/show.html.twig', 'lense');
}
/**
* Displays a form to edit an existing lens entity.
*
* @Route("/{id}/edit", name="lens_edit", methods={"GET", "POST"})
*/
#[Route(path: '/{id}/edit', name: 'lens_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, Lenses $lens)
{
return $this->itemUpdate($request, $lens, 'lenses/edit.html.twig', 'lense', 'lens_show');
}
/**
* Moves a camera to the previouslyOwned table
*
* @Route("/{id}/deacquire", name="lens_deacquire", methods={"POST"})
* @param Request $request
* @param Lenses $lens
* @return RedirectResponse
*/
#[Route(path: '/{id}/deacquire', name: 'lens_deacquire', methods: ['POST'])]
public function deacquireAction(Request $request, Lenses $lens)
{
return $this->itemDeacquire($request, $lens, 'previously-owned-lens_index');
}
/**
* Deletes a lens entity.
*
* @Route("/{id}", name="lens_delete", methods={"DELETE"})
*/
#[Route(path: '/{id}', name: 'lens_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, Lenses $lens)
{
return $this->itemDelete($request, $lens, 'lens_index');
}
/**
* Creates a form to delete a lens entity.
*
@ -119,8 +103,6 @@ class LensesController extends AbstractController
{
return $this->buildForm($lens, 'lens_delete', 'DELETE');
}
/**
* Creates a form to move
*

View File

@ -14,22 +14,19 @@ use Symfony\Component\HttpFoundation\{RedirectResponse, Request};
/**
* Previouslyownedcamera controller.
*
* @Route("previously-owned-camera")
*/
#[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.
*
* @Route("/", name="previously-owned-camera_index", methods={"GET"})
* @throws UnexpectedValueException
*/
#[Route(path: '/', name: 'previously-owned-camera_index', methods: ['GET'])]
public function indexAction()
{
return $this->itemListView('previouslyownedcamera/index.html.twig', 'previouslyOwnedCameras', [
@ -38,44 +35,38 @@ class PreviouslyOwnedCameraController extends AbstractController
'model' => 'ASC',
]);
}
/**
* Finds and displays a previouslyOwnedCamera entity.
*
* @Route("/{id}", name="previously-owned-camera_show", methods={"GET"})
*/
#[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.
*
* @Route("/{id}/edit", name="previously-owned-camera_edit", methods={"GET", "POST"})
* @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
*
* @Route("/{id}/reacquire", name="previously-owned-camera_reacquire", methods={"POST"})
* @param Request $request
* @param PreviouslyOwnedCamera $camera
* @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
*

View File

@ -10,50 +10,41 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Previouslyownedflash controller.
*
* @Route("previously-owned-flash")
*/
#[Route(path: 'previously-owned-flash')]
class PreviouslyOwnedFlashController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = PreviouslyOwnedFlash::class;
protected const FORM = PreviouslyOwnedFlashType::class;
/**
* Lists all previouslyOwnedFlash entities.
*
* @Route("/", name="previously-owned-flash_index", methods={"GET"})
*/
#[Route(path: '/', name: 'previously-owned-flash_index', methods: ['GET'])]
public function indexAction()
{
return $this->itemListView('previouslyownedflash/index.html.twig', 'previouslyOwnedFlashes');
}
/**
* Creates a new previouslyOwnedFlash entity.
*
* @Route("/new", name="previously-owned-flash_new", methods={"GET", "POST"})
*/
#[Route(path: '/new', name: 'previously-owned-flash_new', methods: ['GET', 'POST'])]
public function newAction(Request $request)
{
return $this->itemCreate($request, 'previouslyownedflash/new.html.twig', 'previouslyOwnedFlash', 'previously-owned-flash_show');
}
/**
* Finds and displays a previouslyOwnedFlash entity.
*
* @Route("/{id}", name="previously-owned-flash_show", methods={"GET"})
*/
#[Route(path: '/{id}', name: 'previously-owned-flash_show', methods: ['GET'])]
public function showAction(PreviouslyOwnedFlash $previouslyOwnedFlash)
{
return $this->itemView($previouslyOwnedFlash, 'previouslyownedcamera/show.html.twig', 'previouslyOwnedFlash');
}
/**
* Displays a form to edit an existing previouslyOwnedFlash entity.
*
* @Route("/{id}/edit", name="previously-owned-flash_edit", methods={"GET", "POST"})
*/
#[Route(path: '/{id}/edit', name: 'previously-owned-flash_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, PreviouslyOwnedFlash $previouslyOwnedFlash)
{
return $this->itemUpdate($request, $previouslyOwnedFlash, 'previouslyownedflash/edit.html.twig', 'previouslyOwnedFlash', 'previously-owned-flash_show');

View File

@ -8,21 +8,16 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
/**
* @Route("previously-owned-lens")
*/
#[Route(path: 'previously-owned-lens')]
class PreviouslyOwnedLensesController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = PreviouslyOwnedLenses::class;
protected const FORM = PreviouslyOwnedLensesType::class;
/**
* Lists all previouslyOwnedLense entities.
*
* @Route("/", name="previously-owned-lens_index", methods={"GET"})
*/
#[Route(path: '/', name: 'previously-owned-lens_index', methods: ['GET'])]
public function indexAction()
{
return $this->itemListView('previouslyownedlenses/index.html.twig', 'previouslyOwnedLenses', [
@ -33,22 +28,18 @@ class PreviouslyOwnedLensesController extends AbstractController
'maxFStop' => 'ASC',
]);
}
/**
* Finds and displays a previouslyOwnedLense entity.
*
* @Route("/{id}", name="previously-owned-lens_show", methods={"GET"})
*/
#[Route(path: '/{id}', name: 'previously-owned-lens_show', methods: ['GET'])]
public function showAction(PreviouslyOwnedLenses $previouslyOwnedLens)
{
return $this->itemView($previouslyOwnedLens, 'previouslyownedlenses/show.html.twig', 'previouslyOwnedLense');
}
/**
* Displays a form to edit an existing previouslyOwnedLense entity.
*
* @Route("/{id}/edit", name="previously-owned-lens_edit", methods={"GET", "POST"})
*/
#[Route(path: '/{id}/edit', name: 'previously-owned-lens_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, PreviouslyOwnedLenses $previouslyOwnedLens)
{
return $this->itemUpdate($request, $previouslyOwnedLens, 'previouslyownedlenses/edit.html.twig', 'previouslyOwnedLense', 'previously-owned-lens_show');

View File

@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM;
* Camera
*/
#[ORM\Table(name: 'camera', schema: 'camera')]
#[ORM\Index(name: 'IDX_747C826FC54C8C93', columns: ['type_id'])]
#[ORM\Index(columns: ['type_id'], name: 'IDX_747C826FC54C8C93')]
#[ORM\Entity(repositoryClass: 'App\Repository\CameraRepository')]
class Camera
{