Compare commits

...

4 Commits

28 changed files with 354 additions and 892 deletions

View File

@ -24,7 +24,7 @@ doctrine:
mappings:
App:
is_bundle: false
type: annotation
type: attribute
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App

View File

@ -2,6 +2,8 @@
namespace App\Controller;
use Doctrine\Persistence\ManagerRegistry;
use LogicException;
use App\Entity\Camera;
use App\Form\CameraType;
use Doctrine\ORM\ORMInvalidArgumentException;
@ -14,25 +16,26 @@ 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;
public function __construct(private readonly ManagerRegistry $managerRegistry)
{
}
/**
* Lists all camera entities.
*
* @Route("/", name="camera_index", methods={"GET"})
*/
public function indexAction(): Response
#[Route(path: '/', name: 'camera_index', methods: ['GET'])]
public function indexAction() : Response
{
$em = $this->getDoctrine()->getManager();
$em = $this->managerRegistry->getManager();
$receivedItems = $em->getRepository(self::ENTITY)->findBy([
'received' => true
], [
@ -48,10 +51,8 @@ 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,
@ -61,9 +62,8 @@ class CameraController extends AbstractController
/**
* 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');
@ -71,9 +71,8 @@ class CameraController extends AbstractController
/**
* 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');
@ -82,9 +81,9 @@ class CameraController extends AbstractController
/**
* Displays a form to edit an existing camera entity.
*
* @Route("/{id}/edit", name="camera_edit", methods={"GET", "POST"})
* @throws \LogicException
* @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');
@ -93,10 +92,10 @@ class CameraController extends AbstractController
/**
* Deletes a camera entity.
*
* @Route("/{id}", name="camera_delete", methods={"DELETE"})
* @throws \LogicException
* @throws LogicException
*/
public function deleteAction(Request $request, Camera $camera): RedirectResponse
#[Route(path: '/{id}', name: 'camera_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, Camera $camera) : RedirectResponse
{
return $this->itemDelete($request, $camera, 'camera_index');
}
@ -104,14 +103,11 @@ class CameraController extends AbstractController
/**
* Moves a camera to the previouslyOwned table
*
* @Route("/{id}/deacquire", name="camera_deacquire", methods={"POST"})
* @param Request $request
* @param Camera $camera
* @throws \LogicException
* @throws LogicException
* @throws ORMInvalidArgumentException
* @return RedirectResponse
*/
public function deacquireAction(Request $request, Camera $camera): 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');
}
@ -132,8 +128,6 @@ class CameraController extends AbstractController
* Creates a form to move
*
* @param Camera $camera The camera entity
*
* @return FormInterface
*/
private function createDeacquireForm(Camera $camera): FormInterface
{

View File

@ -4,28 +4,32 @@ namespace App\Controller;
use App\Entity\CameraType;
use App\Form\CameraTypeType;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
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;
public function __construct(private readonly ManagerRegistry $managerRegistry)
{
}
/**
* Lists all cameraType entities.
*
* @Route("/", name="camera-type_index", methods={"GET"})
*/
public function indexAction()
#[Route(path: '/', name: 'camera-type_index', methods: ['GET'])]
public function indexAction(): Response
{
return $this->itemListView('cameratype/index.html.twig', 'cameraTypes', [
'type' => 'ASC',
@ -34,52 +38,44 @@ class CameraTypeController extends AbstractController
/**
* Creates a new cameraType entity.
*
* @Route("/new", name="camera-type_new", methods={"GET", "POST"})
*/
public function newAction(Request $request)
#[Route(path: '/new', name: 'camera-type_new', methods: ['GET', 'POST'])]
public function newAction(Request $request): Response
{
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"})
*/
public function showAction(CameraType $cameraType)
#[Route(path: '/{id}', name: 'camera-type_show', methods: ['GET'])]
public function showAction(CameraType $cameraType): Response
{
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"})
*/
public function editAction(Request $request, CameraType $cameraType)
#[Route(path: '/{id}/edit', name: 'camera-type_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, CameraType $cameraType): RedirectResponse|Response
{
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"})
*/
public function deleteAction(Request $request, CameraType $cameraType)
#[Route(path: '/{id}', name: 'camera-type_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, CameraType $cameraType): RedirectResponse
{
return $this->itemDelete($request, $cameraType, 'camera-type_index');
}
/**
* Creates a form to delete a cameraType entity.
*
* @param CameraType $cameraType The cameraType entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createDeleteForm(CameraType $cameraType)
private function createDeleteForm(CameraType $cameraType): FormInterface
{
return $this->buildForm($cameraType, 'camera-type_delete', 'DELETE');
}

View File

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

View File

@ -2,6 +2,8 @@
namespace App\Controller;
use Doctrine\Persistence\ManagerRegistry;
use LogicException;
use App\Entity\Film;
use App\Form\FilmType;
use Doctrine\Common\Collections\Criteria;
@ -13,26 +15,26 @@ 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;
public function __construct(private readonly ManagerRegistry $managerRegistry)
{
}
/**
* Lists all film entities.
*
* @Route("/", name="film_index", methods={"GET"})
*/
public function indexAction(): Response
#[Route(path: '/', name: 'film_index', methods: ['GET'])]
public function indexAction() : Response
{
$repo = $this->getDoctrine()->getManager()->getRepository(self::ENTITY);
$repo = $this->managerRegistry->getManager()->getRepository(self::ENTITY);
$criteria = Criteria::create()
->where(Criteria::expr()->gt('rollsInCamera', 0))
->orderBy([
@ -41,9 +43,7 @@ class FilmController extends AbstractController
'rollsInCamera' => Criteria::DESC,
'productLine' => Criteria::ASC,
]);
$inCamera = $repo->matching($criteria);
$notInCamera = $repo->findBy([
'rollsInCamera' => 0,
], [
@ -51,7 +51,6 @@ class FilmController extends AbstractController
'productLine' => 'ASC',
'filmFormat' => 'ASC',
]);
return $this->render('film/index.html.twig', [
'in_camera' => $inCamera,
'films' => $notInCamera,
@ -60,9 +59,8 @@ class FilmController extends AbstractController
/**
* 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');
@ -70,9 +68,8 @@ class FilmController extends AbstractController
/**
* 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');
@ -81,9 +78,9 @@ class FilmController extends AbstractController
/**
* Displays a form to edit an existing film entity.
*
* @Route("/{id}/edit", name="film_edit", methods={"GET", "POST"})
* @throws \LogicException
* @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');
@ -92,9 +89,9 @@ class FilmController extends AbstractController
/**
* Deletes a film entity.
*
* @Route("/{id}", name="film_delete", methods={"DELETE"})
* @throws \LogicException
* @throws LogicException
*/
#[Route(path: '/{id}', name: 'film_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, Film $film)
{
return $this->itemDelete($request, $film, 'film_index');

View File

@ -2,82 +2,81 @@
namespace App\Controller;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Form\FormInterface;
use App\Entity\Flash;
use App\Form\FlashType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
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;
public function __construct(private readonly ManagerRegistry $managerRegistry)
{
}
/**
* Lists all flash entities.
*
* @Route("/", name="flash_index", methods={"GET"})
*/
public function indexAction()
#[Route(path: '/', name: 'flash_index', methods: ['GET'])]
public function indexAction(): Response
{
return $this->itemListView('flash/index.html.twig', 'flashes');
}
/**
* Creates a new flash entity.
*
* @Route("/new", name="flash_new", methods={"GET", "POST"})
*/
public function newAction(Request $request)
#[Route(path: '/new', name: 'flash_new', methods: ['GET', 'POST'])]
public function newAction(Request $request): RedirectResponse|Response
{
return $this->itemCreate($request, 'flash/new.html.twig', 'flash', 'flash_show');
}
/**
* Finds and displays a flash entity.
*
* @Route("/{id}", name="flash_show", methods={"GET"})
*/
public function showAction(Flash $flash)
#[Route(path: '/{id}', name: 'flash_show', methods: ['GET'])]
public function showAction(Flash $flash): Response
{
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"})
*/
public function editAction(Request $request, Flash $flash)
#[Route(path: '/{id}/edit', name: 'flash_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, Flash $flash): RedirectResponse|Response
{
return $this->itemUpdate($request, $flash, 'flash/edit.html.twig', 'flash', 'flash_show');
}
/**
* Deletes a flash entity.
*
* @Route("/{id}", name="flash_delete", methods={"DELETE"})
*/
public function deleteAction(Request $request, Flash $flash)
#[Route(path: '/{id}', name: 'flash_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, Flash $flash): RedirectResponse
{
return $this->itemDelete($request, $flash, 'flash_index');
}
/**
* Creates a form to delete a flash entity.
*
* @param Flash $flash The flash entity
*
* @return \Symfony\Component\Form\FormInterface The form
*/
private function createDeleteForm(Flash $flash)
private function createDeleteForm(Flash $flash): FormInterface
{
return $this->buildForm($flash, 'flash_delete', 'DELETE');
}

View File

@ -2,10 +2,13 @@
namespace App\Controller;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\{Request, Response, RedirectResponse};
trait FormControllerTrait {
private readonly ManagerRegistry $managerRegistry;
/**
* Create a form generator
*/
@ -49,7 +52,7 @@ trait FormControllerTrait {
*/
protected function itemListView(string $template, string $templateKey, array $sort = []): Response
{
$em = $this->getDoctrine()->getManager();
$em = $this->managerRegistry->getManager();
$items = $em->getRepository(self::ENTITY)->findBy([], $sort);

View File

@ -2,6 +2,7 @@
namespace App\Controller;
use Doctrine\Persistence\ManagerRegistry;
use App\Entity\Lenses;
use App\Form\LensesType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -11,25 +12,26 @@ 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;
public function __construct(private readonly ManagerRegistry $managerRegistry)
{
}
/**
* Lists all lens entities.
*
* @Route("/", name="lens_index", methods={"GET"})
*/
#[Route(path: '/', name: 'lens_index', methods: ['GET'])]
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$em = $this->managerRegistry->getManager();
$receivedItems = $em->getRepository(self::ENTITY)->findBy([
'received' => true
], [
@ -48,7 +50,6 @@ class LensesController extends AbstractController
'minFocalLength' => 'ASC',
'maxFStop' => 'ASC',
]);
return $this->render('lenses/index.html.twig', [
'not_received' => $newItems,
'lenses' => $receivedItems,
@ -57,9 +58,8 @@ class LensesController extends AbstractController
/**
* 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');
@ -67,9 +67,8 @@ class LensesController extends AbstractController
/**
* 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');
@ -77,9 +76,8 @@ class LensesController extends AbstractController
/**
* 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');
@ -88,11 +86,10 @@ class LensesController extends AbstractController
/**
* 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');
@ -100,9 +97,8 @@ class LensesController extends AbstractController
/**
* 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');
@ -120,13 +116,10 @@ class LensesController extends AbstractController
return $this->buildForm($lens, 'lens_delete', 'DELETE');
}
/**
* Creates a form to move
*
* @param Lenses $lens The lens entity
*
* @return FormInterface
*/
private function createDeacquireForm(Lenses $lens): FormInterface
{

View File

@ -2,6 +2,9 @@
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;
@ -11,22 +14,21 @@ 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
* @throws UnexpectedValueException
*/
#[Route(path: '/', name: 'previously-owned-camera_index', methods: ['GET'])]
public function indexAction()
{
return $this->itemListView('previouslyownedcamera/index.html.twig', 'previouslyOwnedCameras', [
@ -38,9 +40,8 @@ class PreviouslyOwnedCameraController extends AbstractController
/**
* 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');
@ -49,9 +50,9 @@ class PreviouslyOwnedCameraController extends AbstractController
/**
* Displays a form to edit an existing previouslyOwnedCamera entity.
*
* @Route("/{id}/edit", name="previously-owned-camera_edit", methods={"GET", "POST"})
* @throws \LogicException
* @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');
@ -60,25 +61,21 @@ class PreviouslyOwnedCameraController extends AbstractController
/**
* 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 \Doctrine\ORM\ORMInvalidArgumentException
* @throws LogicException
* @throws ORMInvalidArgumentException
* @return RedirectResponse
*/
public function reacquireAction(Request $request, PreviouslyOwnedCamera $camera): 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
*
* @return FormInterface
*/
private function createReacquireForm(PreviouslyOwnedCamera $camera): FormInterface
{

View File

@ -4,36 +4,42 @@ namespace App\Controller;
use App\Entity\PreviouslyOwnedFlash;
use App\Form\PreviouslyOwnedFlashType;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
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;
public function __construct(private readonly ManagerRegistry $managerRegistry)
{
}
/**
* Lists all previouslyOwnedFlash entities.
*
* @Route("/", name="previously-owned-flash_index", methods={"GET"})
*/
public function indexAction()
#[Route(path: '/', name: 'previously-owned-flash_index', methods: ['GET'])]
public function indexAction(): Response
{
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');
@ -41,20 +47,18 @@ class PreviouslyOwnedFlashController extends AbstractController
/**
* Finds and displays a previouslyOwnedFlash entity.
*
* @Route("/{id}", name="previously-owned-flash_show", methods={"GET"})
*/
public function showAction(PreviouslyOwnedFlash $previouslyOwnedFlash)
#[Route(path: '/{id}', name: 'previously-owned-flash_show', methods: ['GET'])]
public function showAction(PreviouslyOwnedFlash $previouslyOwnedFlash): Response
{
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"})
*/
public function editAction(Request $request, PreviouslyOwnedFlash $previouslyOwnedFlash)
#[Route(path: '/{id}/edit', name: 'previously-owned-flash_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, PreviouslyOwnedFlash $previouslyOwnedFlash): RedirectResponse|Response
{
return $this->itemUpdate($request, $previouslyOwnedFlash, 'previouslyownedflash/edit.html.twig', 'previouslyOwnedFlash', 'previously-owned-flash_show');
}

View File

@ -8,21 +8,18 @@ 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', [
@ -36,9 +33,8 @@ class PreviouslyOwnedLensesController extends AbstractController
/**
* 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');
@ -46,9 +42,8 @@ class PreviouslyOwnedLensesController extends AbstractController
/**
* 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

@ -6,18 +6,13 @@ use Doctrine\ORM\Mapping as ORM;
/**
* Battery Type
*
* @ORM\Table(name="battery_type", schema="camera")
* @ORM\Entity
*/
#[ORM\Table(name: 'battery_type', schema: 'camera')]
#[ORM\Entity]
class BatteryType
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int $id;
}

View File

@ -2,26 +2,21 @@
namespace App\Entity;
use App\Repository\CameraRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* Camera
*
* @ORM\Table(name="camera", schema="camera", indexes={
@ORM\Index(name="IDX_747C826FC54C8C93", columns={"type_id"})
})
* @ORM\Entity(repositoryClass="App\Repository\CameraRepository")
*/
class Camera {
#[ORM\Table(name: 'camera', schema: 'camera')]
#[ORM\Index(columns: ['type_id'], name: 'IDX_747C826FC54C8C93')]
#[ORM\Entity(repositoryClass: CameraRepository::class)]
class Camera
{
use CameraTrait;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @ORM\SequenceGenerator(sequenceName="camera__id_seq", allocationSize=1, initialValue=1)
*/
private $id;
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'camera__id_seq', allocationSize: 1, initialValue: 1)]
private int $id;
}

View File

@ -15,124 +15,51 @@ trait CameraTrait
{
use PurchasePriceTrait;
/**
* @var CameraType
*
* @ORM\ManyToOne(targetEntity="CameraType")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="type_id", referencedColumnName="id")
* })
*/
private ?CameraType $type;
#[ORM\ManyToOne(targetEntity: 'CameraType')]
#[ORM\JoinColumn(name: 'type_id', referencedColumnName: 'id', nullable: false)]
private readonly CameraType $type;
/**
* @var string
*
* @ORM\Column(name="brand", type="string", length=64, nullable=false)
*/
private string $brand;
#[ORM\Column(name: 'brand', type: 'string', length: 64, nullable: false)]
private readonly string $brand;
/**
* @var string
*
* @ORM\Column(name="mount", type="string", length=32, nullable=false)
*/
private string $mount;
#[ORM\Column(name: 'mount', type: 'string', length: 32, nullable: false)]
private readonly string $mount;
/**
* @var string
*
* @ORM\Column(name="model", type="string", length=255, nullable=false)
*/
private string $model;
#[ORM\Column(name: 'model', type: 'string', length: 255, nullable: false)]
private readonly string $model;
/**
* @var boolean
*
* @ORM\Column(name="is_digital", type="boolean", nullable=false)
*/
private bool $isDigital;
#[ORM\Column(name: 'is_digital', type: 'boolean', nullable: false)]
private readonly bool $isDigital;
/**
* @var string
*
* @ORM\Column(name="crop_factor", type="decimal", precision=10, scale=0, nullable=false)
*/
#[ORM\Column(name: 'crop_factor', type: 'decimal', precision: 10, scale: 0, nullable: false)]
private string $cropFactor = '1.0';
/**
* @var boolean
*
* @ORM\Column(name="is_working", type="boolean", nullable=false)
*/
private bool $isWorking;
#[ORM\Column(name: 'is_working', type: 'boolean', nullable: false)]
private readonly bool $isWorking;
/**
* @var string
*
* @ORM\Column(name="notes", type="text", nullable=true)
*/
private ?string $notes;
#[ORM\Column(name: 'notes', type: 'text', nullable: true)]
private readonly ?string $notes;
/**
* @var string
*
* @ORM\Column(name="serial", type="string", length=20, nullable=false)
*/
private string $serial;
#[ORM\Column(name: 'serial', type: 'string', length: 20, nullable: false)]
private readonly string $serial;
/**
* @var boolean
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false)
*/
#[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: false)]
private bool $formerlyOwned = FALSE;
/**
* @var string
*
* @ORM\Column(name="purchase_price", type="money", nullable=true)
*/
private $purchasePrice;
#[ORM\Column(name: 'battery_type', type: 'string', nullable: true)]
private readonly ?string $batteryType;
/**
* @var string
*
* @ORM\Column(name="battery_type", type="string", nullable=true)
*/
private ?string $batteryType;
/**
* @var string
*
* @ORM\Column(name="film_format", type="string", nullable=true)
*/
#[ORM\Column(name: 'film_format', type: 'string', nullable: true)]
private ?string $filmFormat = '135';
/**
* @var boolean
*
* @ORM\Column(name="received", type="boolean", nullable=true)
*/
#[ORM\Column(name: 'received', type: 'boolean', nullable: true)]
private ?bool $received = FALSE;
/**
* Get id
*
* @return integer
*/
public function getId(): int
{
return $this->id;
}
/**
* Set type
*
* @param CameraType $type
*
* @return self
*/
public function setType(CameraType $type = null): self
{
$this->type = $type;
@ -140,23 +67,11 @@ trait CameraTrait
return $this;
}
/**
* Get type
*
* @return CameraType
*/
public function getType(): ?CameraType
public function getType(): CameraType
{
return $this->type;
}
/**
* Set brand
*
* @param string $brand
*
* @return self
*/
public function setBrand(string $brand): self
{
$this->brand = $brand;
@ -164,23 +79,11 @@ trait CameraTrait
return $this;
}
/**
* Get brand
*
* @return string
*/
public function getBrand(): ?string
public function getBrand(): string
{
return $this->brand;
}
/**
* Set mount
*
* @param string $mount
*
* @return self
*/
public function setMount(string $mount): self
{
$this->mount = $mount;
@ -188,23 +91,11 @@ trait CameraTrait
return $this;
}
/**
* Get mount
*
* @return string
*/
public function getMount(): ?string
public function getMount(): string
{
return $this->mount;
}
/**
* Set model
*
* @param string $model
*
* @return self
*/
public function setModel(string $model): self
{
$this->model = $model;
@ -212,23 +103,11 @@ trait CameraTrait
return $this;
}
/**
* Get model
*
* @return string
*/
public function getModel(): ?string
public function getModel(): string
{
return $this->model;
}
/**
* Set isDigital
*
* @param boolean $isDigital
*
* @return self
*/
public function setIsDigital(bool $isDigital): self
{
$this->isDigital = $isDigital;
@ -236,23 +115,11 @@ trait CameraTrait
return $this;
}
/**
* Get isDigital
*
* @return boolean
*/
public function getIsDigital(): ?bool
public function getIsDigital(): bool
{
return $this->isDigital;
}
/**
* Set cropFactor
*
* @param string $cropFactor
*
* @return self
*/
public function setCropFactor(string $cropFactor): self
{
$this->cropFactor = $cropFactor;
@ -260,23 +127,11 @@ trait CameraTrait
return $this;
}
/**
* Get cropFactor
*
* @return string
*/
public function getCropFactor(): string
{
return $this->cropFactor;
}
/**
* Set isWorking
*
* @param boolean $isWorking
*
* @return self
*/
public function setIsWorking(bool $isWorking): self
{
$this->isWorking = $isWorking;
@ -284,155 +139,78 @@ trait CameraTrait
return $this;
}
/**
* Get isWorking
*
* @return boolean
*/
public function getIsWorking(): ?bool
public function getIsWorking(): bool
{
return $this->isWorking;
}
/**
* Set notes
*
* @param string $notes
*
* @return self
*/
public function setNotes($notes): self
public function setNotes(string $notes): self
{
$this->notes = $notes;
return $this;
}
/**
* Get notes
*
* @return string
*/
public function getNotes(): string
{
return $this->notes ?? '';
}
/**
* Set serial
*
* @param string $serial
*
* @return self
*/
public function setSerial($serial): self
public function setSerial(string $serial): self
{
$this->serial = $serial;
return $this;
}
/**
* Get serial
*
* @return string
*/
public function getSerial(): string
{
return $this->serial ?? '';
}
/**
* Set formerlyOwned
*
* @param boolean $formerlyOwned
*
* @return self
*/
public function setFormerlyOwned($formerlyOwned): self
public function setFormerlyOwned(bool $formerlyOwned): self
{
$this->formerlyOwned = $formerlyOwned;
return $this;
}
/**
* Get formerlyOwned
*
* @return boolean
*/
public function getFormerlyOwned(): ?bool
public function getFormerlyOwned(): bool
{
return $this->formerlyOwned;
}
/**
* Set batteryType
*
* @param string $batteryType
*
* @return self
*/
public function setBatteryType($batteryType): self
public function setBatteryType(string $batteryType): self
{
$this->batteryType = $batteryType;
return $this;
}
/**
* Get batteryType
*
* @return string
*/
public function getBatteryType(): ?string
public function getBatteryType(): string
{
return $this->batteryType;
return $this->batteryType ?? '';
}
/**
* Set filmFormat
*
* @param string $filmFormat
*
* @return self
*/
public function setFilmFormat($filmFormat): self
public function setFilmFormat(string $filmFormat): self
{
$this->filmFormat = $filmFormat;
return $this;
}
/**
* Get filmFormat
*
* @return string
*/
public function getFilmFormat(): string
{
return $this->filmFormat;
return $this->filmFormat ?? '';
}
/**
* Set received
*
* @param boolean $received
*
* @return self
*/
public function setReceived($received): self
public function setReceived(bool $received): self
{
$this->received = $received;
return $this;
}
/**
* Get received
*
* @return boolean
*/
public function getReceived(): bool
{
return $this->received;

View File

@ -2,56 +2,44 @@
namespace App\Entity;
use Stringable;
use Doctrine\ORM\Mapping as ORM;
/**
* CameraType
*
* @ORM\Table(name="camera_type", schema="camera")
* @ORM\Entity
*/
class CameraType
#[ORM\Table(name: 'camera_type', schema: 'camera')]
#[ORM\Entity]
class CameraType implements Stringable
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @ORM\SequenceGenerator(sequenceName="camera.camera_type_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'camera.camera_type_id_seq', allocationSize: 1, initialValue: 1)]
private int $id;
/**
* @var string
*
* @ORM\Column(name="type", type="string", length=255, nullable=false)
*/
#[ORM\Column(name: 'type', type: 'string', length: 255, nullable: false)]
private string $type;
/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private ?string $description;
#[ORM\Column(name: 'description', type: 'text', nullable: true)]
private ?string $description = null;
/**
* Value for serialization
*
* @return string
*/
public function __toString(): string
{
return $this->type;
}
/**
* Get id
*
* @return integer
*/
public function getId(): int
{
@ -61,9 +49,7 @@ class CameraType
/**
* Set type
*
* @param string $type
*
* @return CameraType
*/
public function setType(string $type): self
{
@ -75,9 +61,7 @@ class CameraType
/**
* Set description
*
* @param string $description
*
* @return CameraType
*/
public function setDescription(string $description): self
{

View File

@ -6,115 +6,94 @@ use Doctrine\ORM\Mapping as ORM;
/**
* Camera
*
* @ORM\Table(name="film", schema="camera")
* @ORM\Entity
*/
class Film {
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
#[ORM\Table(name: 'film', schema: 'camera')]
#[ORM\Entity]
class Film
{
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int $id;
/**
* @var string
*
* @ORM\Column(name="brand", type="string", nullable=false)
*/
#[ORM\Column(name: 'brand', type: 'string', nullable: false)]
private string $brand;
/**
* @var string
*
* @ORM\Column(name="product_line", type="string", nullable=true)
*/
private ?string $productLine;
#[ORM\Column(name: 'product_line', type: 'string', nullable: true)]
private ?string $productLine = null;
/**
* @var string
*
* @ORM\Column(name="film_name", type="string", nullable=false)
*/
#[ORM\Column(name: 'film_name', type: 'string', nullable: false)]
private string $filmName;
/**
* @var string
*
* @ORM\Column(name="film_alias", type="string", nullable=true)
*/
private ?string $filmAlias;
#[ORM\Column(name: 'film_alias', type: 'string', nullable: true)]
private ?string $filmAlias = null;
/**
* @var int
*
* @ORM\Column(name="film_speed_asa", type="integer", nullable=false)
*/
#[ORM\Column(name: 'film_speed_asa', type: 'integer', nullable: false)]
private int $filmSpeedAsa;
/**
* @var int
*
* @ORM\Column(name="film_speed_din", type="integer", nullable=false)
*/
#[ORM\Column(name: 'film_speed_din', type: 'integer', nullable: false)]
private int $filmSpeedDin;
/**
* @var string
*
* @ORM\Column(name="film_format", type="string", nullable=false)
*/
#[ORM\Column(name: 'film_format', type: 'string', nullable: false)]
private string $filmFormat;
/**
* @var string
*
* @ORM\Column(name="film_base", type="string", nullable=false, options={"default"="Cellulose Triacetate"})
*/
#[ORM\Column(name: 'film_base', type: 'string', nullable: false, options: ['default' => 'Cellulose Triacetate'])]
private string $filmBase = 'Cellulose Triacetate';
/**
* @var int
*
* @ORM\Column(name="unused_rolls", type="integer", nullable=false, options={"default"=0})
*/
#[ORM\Column(name: 'unused_rolls', type: 'integer', nullable: false, options: ['default' => 0])]
private int $unusedRolls = 0;
/**
* @var int
*
* @ORM\Column(name="rolls_in_camera", type="integer", nullable=false, options={"default"=0})
*/
#[ORM\Column(name: 'rolls_in_camera', type: 'integer', nullable: false, options: ['default' => 0])]
private int $rollsInCamera = 0;
/**
* @var int
*
* @ORM\Column(name="developed_rolls", type="integer", nullable=false, options={"default"=0})
*/
#[ORM\Column(name: 'developed_rolls', type: 'integer', nullable: false, options: ['default' => 0])]
private int $developedRolls = 0;
/**
* @var string
*
* @ORM\Column(name="chemistry", type="string", nullable=false, options={"default"="C-41"})
*/
#[ORM\Column(name: 'chemistry', type: 'string', nullable: false, options: ['default' => 'C-41'])]
private string $chemistry = 'C-41';
/**
* @var string
*
* @ORM\Column(name="notes", type="text", nullable=true)
*/
private ?string $notes;
#[ORM\Column(name: 'notes', type: 'text', nullable: true)]
private ?string $notes = null;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
@ -128,10 +107,6 @@ class Film {
return $this->brand;
}
/**
* @param string $brand
* @return self
*/
public function setBrand(string $brand): self
{
$this->brand = $brand;
@ -148,7 +123,6 @@ class Film {
/**
* @param string $productLine
* @return self
*/
public function setProductLine(?string $productLine): self
{
@ -164,10 +138,6 @@ class Film {
return $this->filmName;
}
/**
* @param string $filmName
* @return self
*/
public function setFilmName(string $filmName): self
{
$this->filmName = $filmName;
@ -182,10 +152,6 @@ class Film {
return $this->filmAlias;
}
/**
* @param string $filmAlias
* @return self
*/
public function setFilmAlias(string $filmAlias): self
{
$this->filmAlias = $filmAlias;
@ -200,10 +166,6 @@ class Film {
return $this->filmSpeedAsa;
}
/**
* @param int $filmSpeedAsa
* @return self
*/
public function setFilmSpeedAsa(int $filmSpeedAsa): self
{
$this->filmSpeedAsa = $filmSpeedAsa;
@ -218,10 +180,6 @@ class Film {
return $this->filmSpeedDin;
}
/**
* @param int $filmSpeedDin
* @return self
*/
public function setFilmSpeedDin(int $filmSpeedDin): self
{
$this->filmSpeedDin = $filmSpeedDin;
@ -236,10 +194,6 @@ class Film {
return $this->filmFormat;
}
/**
* @param string $filmFormat
* @return self
*/
public function setFilmFormat(string $filmFormat): self
{
$this->filmFormat = $filmFormat;
@ -254,10 +208,6 @@ class Film {
return $this->filmBase;
}
/**
* @param string $filmBase
* @return self
*/
public function setFilmBase(string $filmBase): self
{
$this->filmBase = $filmBase;
@ -272,10 +222,6 @@ class Film {
return $this->unusedRolls;
}
/**
* @param int $unusedRolls
* @return self
*/
public function setUnusedRolls(int $unusedRolls): self
{
$this->unusedRolls = $unusedRolls;
@ -290,10 +236,6 @@ class Film {
return $this->rollsInCamera;
}
/**
* @param int $rollsInCamera
* @return self
*/
public function setRollsInCamera(int $rollsInCamera): self
{
$this->rollsInCamera = $rollsInCamera;
@ -308,10 +250,6 @@ class Film {
return $this->developedRolls;
}
/**
* @param int $developedRolls
* @return self
*/
public function setDevelopedRolls(int $developedRolls): self
{
$this->developedRolls = $developedRolls;
@ -326,10 +264,6 @@ class Film {
return $this->chemistry;
}
/**
* @param string $chemistry
* @return self
*/
public function setChemistry(string $chemistry): self
{
$this->chemistry = $chemistry;
@ -344,10 +278,6 @@ class Film {
return $this->notes;
}
/**
* @param string $notes
* @return self
*/
public function setNotes(string $notes): self
{
$this->notes = $notes;

View File

@ -4,31 +4,25 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="film_format", schema="camera")
* @ORM\Entity
*/
#[ORM\Table(name: 'film_format', schema: 'camera')]
#[ORM\Entity]
class FilmFormat
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
/**
* @var int
*
* @ORM\Column(name="number_id", type="integer")
*/
#[ORM\Column(name: 'number_id', type: 'integer')]
private int $numberId;
/**
* @var string
*
* @ORM\Column(name="name", type="string")
*/
#[ORM\Column(name: 'name', type: 'string')]
private string $name;
/**
@ -47,10 +41,6 @@ class FilmFormat
return $this->numberId;
}
/**
* @param int $numberId
* @return self
*/
public function setNumberId(int $numberId): self
{
$this->numberId = $numberId;
@ -65,10 +55,6 @@ class FilmFormat
return $this->name;
}
/**
* @param string $name
* @return self
*/
public function setName(string $name): self
{
$this->name = $name;

View File

@ -6,36 +6,27 @@ use Doctrine\ORM\Mapping as ORM;
/**
* Camera.flash
*
* @ORM\Table(name="flash", schema="camera")
* @ORM\Entity
*/
#[ORM\Table(name: 'flash', schema: 'camera')]
#[ORM\Entity]
class Flash
{
use FlashTrait;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @ORM\SequenceGenerator(sequenceName="camera.flash_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'camera.flash_id_seq', allocationSize: 1, initialValue: 1)]
private int $id;
/**
* @var boolean
*
* @ORM\Column(name="received", type="boolean", nullable=false, options={"default" : false})
*/
#[ORM\Column(name: 'received', type: 'boolean', nullable: false, options: ['default' => false])]
private bool $received = false;
/**
* @var boolean
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false, options={"default" : false})
*/
#[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: false, options: ['default' => false])]
private bool $formerlyOwned = false;
}

View File

@ -8,95 +8,39 @@ trait FlashTrait
{
use PurchasePriceTrait;
/**
* @var string
*
* @ORM\Column(name="brand", type="string", nullable=false)
*/
private string $brand;
#[ORM\Column(name: 'brand', type: 'string', nullable: false)]
private readonly string $brand;
/**
* @var string
*
* @ORM\Column(name="model", type="string", nullable=false)
*/
private string $model;
#[ORM\Column(name: 'model', type: 'string', nullable: false)]
private readonly string $model;
/**
* @var boolean
*
* @ORM\Column(name="is_auto_flash", type="boolean", nullable=false)
*/
#[ORM\Column(name: 'is_auto_flash', type: 'boolean', nullable: false)]
private bool $isAutoFlash = false;
/**
* @var boolean
*
* @ORM\Column(name="is_ttl", type="boolean", nullable=false)
*/
#[ORM\Column(name: 'is_ttl', type: 'boolean', nullable: false)]
private bool $isTtl = false;
/**
* @var string
*
* @ORM\Column(name="ttl_type", type="string", nullable=false)
*/
#[ORM\Column(name: 'ttl_type', type: 'string', nullable: false)]
private string $ttlType = 'N / A';
/**
* @var boolean
*
* @ORM\Column(name="is_p_ttl", type="boolean", nullable=false)
*/
#[ORM\Column(name: 'is_p_ttl', type: 'boolean', nullable: false)]
private bool $isPTtl = false;
/**
* @var string
*
* @ORM\Column(name="p_ttl_type", type="string", nullable=false)
*/
#[ORM\Column(name: 'p_ttl_type', type: 'string', nullable: false)]
private string $pTtlType = 'N / A';
/**
* @var string
*
* @ORM\Column(name="guide_number", type="string", nullable=true)
*/
private string $guideNumber;
#[ORM\Column(name: 'guide_number', type: 'string', nullable: true)]
private ?string $guideNumber = '';
/**
* @var string
*
* @ORM\Column(name="purchase_price", type="money", nullable=true)
*/
private ?string $purchasePrice;
/**
* @var string
*
* @ORM\Column(name="batteries", type="string", nullable=false)
*/
#[ORM\Column(name: 'batteries', type: 'string', nullable: false)]
private string $batteries = '4x AA';
/**
* @var string
*
* @ORM\Column(name="notes", type="text", nullable=true)
*/
private ?string $notes;
#[ORM\Column(name: 'notes', type: 'text', nullable: true)]
private readonly ?string $notes;
/**
* @var string
*
* @ORM\Column(name="serial", type="string", nullable=true)
*/
private ?string $serial;
#[ORM\Column(name: 'serial', type: 'string', nullable: true)]
private readonly ?string $serial;
/**
* Get id
*
* @return integer
*/
public function getId(): int
{
return $this->id;
@ -105,11 +49,9 @@ trait FlashTrait
/**
* Set brand
*
* @param string $brand
*
* @return self
*/
public function setBrand($brand)
public function setBrand(string $brand): self
{
$this->brand = $brand;
@ -250,8 +192,6 @@ trait FlashTrait
* Set pTtlType
*
* @param string $pTtlType
*
* @return self
*/
public function setPTtlType($pTtlType): self
{

View File

@ -2,148 +2,123 @@
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
trait LensTrait
{
use PurchasePriceTrait;
/**
* @var string
*
* @ORM\Column(name="brand", type="string", length=64, nullable=true)
*/
private ?string $brand;
#[ORM\Column(name: 'brand', type: 'string', length: 64, nullable: true)]
private readonly ?string $brand;
/**
* @var string
*
* @ORM\Column(name="coatings", type="string", length=64, nullable=true)
*/
private ?string $coatings;
#[ORM\Column(name: 'coatings', type: 'string', length: 64, nullable: true)]
private readonly ?string $coatings;
/**
* @var string
*
* @ORM\Column(name="product_line", type="string", length=64, nullable=true)
*/
private ?string $productLine;
#[ORM\Column(name: 'product_line', type: 'string', length: 64, nullable: true)]
private readonly ?string $productLine;
/**
* @var string
*
* @ORM\Column(name="model", type="string", length=64, nullable=true)
*/
private ?string $model;
#[ORM\Column(name: 'model', type: 'string', length: 64, nullable: true)]
private readonly ?string $model;
/**
* @var string
*
* @ORM\Column(name="min_f_stop", type="string", length=10, nullable=true)
*/
private ?string $minFStop;
#[ORM\Column(name: 'min_f_stop', type: 'string', length: 10, nullable: true)]
private readonly ?string $minFStop;
/**
* @var float
*
* @ORM\Column(name="max_f_stop", type="float", precision=10, scale=0, nullable=true)
*/
private ?float $maxFStop;
#[ORM\Column(name: 'max_f_stop', type: 'float', precision: 10, scale: 0, nullable: true)]
private readonly ?float $maxFStop;
/**
* @var integer
*
* @ORM\Column(name="min_focal_length", type="integer", nullable=true)
*/
private ?int $minFocalLength;
#[ORM\Column(name: 'min_focal_length', type: 'integer', nullable: true)]
private readonly ?int $minFocalLength;
/**
* @var integer
*
* @ORM\Column(name="max_focal_length", type="integer", nullable=true)
*/
private ?int $maxFocalLength;
#[ORM\Column(name: 'max_focal_length', type: 'integer', nullable: true)]
private readonly ?int $maxFocalLength;
/**
* @var string
*
* @ORM\Column(name="serial", type="string", length=10, nullable=true)
*/
private ?string $serial;
#[ORM\Column(name: 'serial', type: 'string', length: 10, nullable: true)]
private readonly ?string $serial;
/**
* @var string
*
* @ORM\Column(name="purchase_price", type="money", nullable=true)
*/
private ?string $purchasePrice;
#[ORM\Column(name: 'notes', type: 'text', nullable: true)]
private readonly ?string $notes;
/**
* @var string
*
* @ORM\Column(name="notes", type="text", nullable=true)
*/
private ?string $notes;
/**
* @var string
*
* @ORM\Column(name="image_size", type="string", nullable=false, options={"default"="35mm"})
*/
#[ORM\Column(name: 'image_size', type: 'string', nullable: false, options: ['default' => '35mm'])]
private string $imageSize = '35mm';
/**
* @var string
*
* @ORM\Column(name="mount", type="string", length=40, nullable=true)
*/
private ?string $mount;
#[ORM\Column(name: 'mount', type: 'string', length: 40, nullable: true)]
private readonly ?string $mount;
/**
* @var string
*
* @ORM\Column(name="front_filter_size", type="decimal", precision=10, scale=0, nullable=true)
*/
private ?string $frontFilterSize;
#[ORM\Column(name: 'front_filter_size', type: 'decimal', precision: 10, scale: 0, nullable: true)]
private readonly ?string $frontFilterSize;
/**
* @var string
*
* @ORM\Column(name="rear_filter_size", type="decimal", precision=10, scale=0, nullable=true)
*/
private? string $rearFilterSize;
#[ORM\Column(name: 'rear_filter_size', type: 'decimal', precision: 10, scale: 0, nullable: true)]
private readonly ? string $rearFilterSize;
/**
* @var boolean
*
* @ORM\Column(name="is_teleconverter", type="boolean", nullable=false)
*/
#[ORM\Column(name: 'is_teleconverter', type: 'boolean', nullable: false)]
private bool $isTeleconverter = false;
/**
* @var integer
*
* @ORM\Column(name="design_elements", type="smallint", nullable=true)
*/
private ?int $designElements;
#[ORM\Column(name: 'design_elements', type: 'smallint', nullable: true)]
private readonly ?int $designElements;
/**
* @var integer
*
* @ORM\Column(name="design_groups", type="smallint", nullable=true)
*/
private ?int $designGroups;
#[ORM\Column(name: 'design_groups', type: 'smallint', nullable: true)]
private readonly ?int $designGroups;
/**
* @var integer
*
* @ORM\Column(name="aperture_blades", type="smallint", nullable=true)
*/
private ?int $apertureBlades;
#[ORM\Column(name: 'aperture_blades', type: 'smallint', nullable: true)]
private readonly ?int $apertureBlades;
/**
* Get id
*
* @return integer
*/
public function getId(): int
{
@ -154,8 +129,6 @@ trait LensTrait
* Set brand
*
* @param string $brand
*
* @return self
*/
public function setBrand($brand): self
{
@ -178,8 +151,6 @@ trait LensTrait
* Set coatings
*
* @param string $coatings
*
* @return self
*/
public function setCoatings($coatings): self
{
@ -202,8 +173,6 @@ trait LensTrait
* Set productLine
*
* @param string $productLine
*
* @return self
*/
public function setProductLine($productLine): self
{
@ -226,8 +195,6 @@ trait LensTrait
* Set model
*
* @param string $model
*
* @return self
*/
public function setModel($model): self
{
@ -250,8 +217,6 @@ trait LensTrait
* Set minFStop
*
* @param string $minFStop
*
* @return self
*/
public function setMinFStop($minFStop): self
{
@ -274,8 +239,6 @@ trait LensTrait
* Set maxFStop
*
* @param float $maxFStop
*
* @return self
*/
public function setMaxFStop($maxFStop): self
{
@ -298,8 +261,6 @@ trait LensTrait
* Set minFocalLength
*
* @param integer $minFocalLength
*
* @return self
*/
public function setMinFocalLength($minFocalLength): self
{
@ -322,8 +283,6 @@ trait LensTrait
* Set maxFocalLength
*
* @param integer $maxFocalLength
*
* @return self
*/
public function setMaxFocalLength($maxFocalLength): self
{
@ -346,8 +305,6 @@ trait LensTrait
* Set serial
*
* @param string $serial
*
* @return self
*/
public function setSerial($serial): self
{
@ -358,8 +315,6 @@ trait LensTrait
/**
* Get serial
*
* @return string
*/
public function getSerial(): string
{
@ -370,8 +325,6 @@ trait LensTrait
* Set notes
*
* @param string $notes
*
* @return self
*/
public function setNotes(?string $notes): self
{
@ -382,8 +335,6 @@ trait LensTrait
/**
* Get notes
*
* @return string
*/
public function getNotes(): string
{
@ -392,8 +343,6 @@ trait LensTrait
/**
* Get image size
*
* @return string
*/
public function getImageSize(): string
{
@ -402,9 +351,6 @@ trait LensTrait
/**
* Set image size
*
* @param string $imageSize
* @return self
*/
public function setImageSize(string $imageSize): self
{
@ -416,8 +362,6 @@ trait LensTrait
* Set mount
*
* @param string $mount
*
* @return self
*/
public function setMount($mount): self
{
@ -440,8 +384,6 @@ trait LensTrait
* Set received
*
* @param boolean $received
*
* @return self
*/
public function setReceived($received): self
{
@ -464,8 +406,6 @@ trait LensTrait
* Set formerlyOwned
*
* @param boolean $formerlyOwned
*
* @return self
*/
public function setFormerlyOwned($formerlyOwned): self
{
@ -488,8 +428,6 @@ trait LensTrait
* Set frontFilterSize
*
* @param string $frontFilterSize
*
* @return self
*/
public function setFrontFilterSize($frontFilterSize): self
{
@ -512,8 +450,6 @@ trait LensTrait
* Set rearFilterSize
*
* @param string $rearFilterSize
*
* @return self
*/
public function setRearFilterSize($rearFilterSize): self
{
@ -536,8 +472,6 @@ trait LensTrait
* Set isTeleconverter
*
* @param boolean $isTeleconverter
*
* @return self
*/
public function setIsTeleconverter($isTeleconverter): self
{
@ -560,8 +494,6 @@ trait LensTrait
* Set designElements
*
* @param integer $designElements
*
* @return self
*/
public function setDesignElements($designElements): self
{
@ -584,8 +516,6 @@ trait LensTrait
* Set designGroups
*
* @param integer $designGroups
*
* @return self
*/
public function setDesignGroups($designGroups): self
{
@ -608,8 +538,6 @@ trait LensTrait
* Set apertureBlades
*
* @param integer $apertureBlades
*
* @return self
*/
public function setApertureBlades($apertureBlades): self
{

View File

@ -2,39 +2,26 @@
namespace App\Entity;
use App\Repository\LensesRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* Camera.lenses
*
* @ORM\Table(name="lenses", schema="camera")
* @ORM\Entity(repositoryClass="App\Repository\LensesRepository")
*/
#[ORM\Table(name: 'lenses', schema: 'camera')]
#[ORM\Entity(repositoryClass: LensesRepository::class)]
class Lenses
{
use LensTrait;
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'camera.lenses_id_seq', allocationSize: 1, initialValue: 1)]
private int $id;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @ORM\SequenceGenerator(sequenceName="camera.lenses_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
#[ORM\Column(name: 'received', type: 'boolean', nullable: false)]
private bool $received = false;
/**
* @var boolean
*
* @ORM\Column(name="received", type="boolean", nullable=false)
*/
private $received = false;
/**
* @var boolean
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false)
*/
private $formerlyOwned = false;
#[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: false)]
private bool $formerlyOwned = false;
}

View File

@ -2,25 +2,21 @@
namespace App\Entity;
use App\Repository\CameraRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* Camera.previouslyOwnedCamera
*
* @ORM\Table(name="previously_owned_camera", schema="camera", indexes={@ORM\Index(name="IDX_6EF94C6BC54C8C93", columns={"type_id"})})
* @ORM\Entity(repositoryClass="App\Repository\CameraRepository")
*/
#[ORM\Table(name: 'previously_owned_camera', schema: 'camera')]
#[ORM\Index(name: 'IDX_6EF94C6BC54C8C93', columns: ['type_id'])]
#[ORM\Entity(repositoryClass: CameraRepository::class)]
class PreviouslyOwnedCamera
{
use CameraTrait;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @ORM\SequenceGenerator(sequenceName="prevously_owned_camera_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'prevously_owned_camera_id_seq', allocationSize: 1, initialValue: 1)]
private int $id;
}

View File

@ -6,35 +6,21 @@ use Doctrine\ORM\Mapping as ORM;
/**
* Camera.flash
*
* @ORM\Table(name="previously_owned_flash", schema="camera")
* @ORM\Entity
*/
#[ORM\Table(name: 'previously_owned_flash', schema: 'camera')]
#[ORM\Entity]
class PreviouslyOwnedFlash
{
use FlashTrait;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int $id;
/**
* @var boolean
*
* @ORM\Column(name="received", type="boolean", nullable=false, options={"default" : true})
*/
#[ORM\Column(name: 'received', type: 'boolean', nullable: false, options: ['default' => true])]
private bool $received = true;
/**
* @var boolean
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false, options={"default" : true})
*/
#[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: false, options: ['default' => true])]
private bool $formerlyOwned = true;
}

View File

@ -2,37 +2,31 @@
namespace App\Entity;
use App\Repository\LensesRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* Camera.previouslyOwnedLenses
*
* @ORM\Table(name="previously_owned_lenses", schema="camera")
* @ORM\Entity(repositoryClass="App\Repository\LensesRepository")
*/
#[ORM\Table(name: 'previously_owned_lenses', schema: 'camera')]
#[ORM\Entity(repositoryClass: LensesRepository::class)]
class PreviouslyOwnedLenses
{
use LensTrait;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int $id;
/**
* @var boolean
*
* @ORM\Column(name="received", type="boolean", nullable=false)
*/
#[ORM\Column(name: 'received', type: 'boolean', nullable: false)]
private bool $received = true;
/**
* @var boolean
*
* @ORM\Column(name="formerly_owned", type="boolean", nullable=false)
*/
#[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: false)]
private bool $formerlyOwned = true;
}

View File

@ -2,31 +2,24 @@
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
trait PurchasePriceTrait
{
/**
* Set purchasePrice
*
* @param string $purchasePrice
*
* @return self
*/
public function setPurchasePrice($purchasePrice): self
#[ORM\Column(name: 'purchase_price', type: 'money', nullable: true)]
private ?string $purchasePrice = null;
public function setPurchasePrice(?string $purchasePrice): self
{
$this->purchasePrice = $purchasePrice;
return $this;
}
/**
* Get purchasePrice
*
* @return string
*/
public function getPurchasePrice()
public function getPurchasePrice(): string
{
if (empty($this->purchasePrice)) {
return 0;
return '0';
}
return $this->purchasePrice;

View File

@ -2,6 +2,8 @@
namespace App\Repository;
use ReflectionObject;
use Throwable;
trait AcquireTrait {
/**
@ -15,8 +17,8 @@ trait AcquireTrait {
{
$em = $this->getEntityManager();
$old = new \ReflectionObject($currentRecord);
$new = new \ReflectionObject($newRecord);
$old = new ReflectionObject($currentRecord);
$new = new ReflectionObject($newRecord);
foreach ($old->getProperties() as $property) {
$propertyName = $property->getName();
@ -34,7 +36,7 @@ trait AcquireTrait {
$em->remove($currentRecord);
$em->flush();
}
catch (\Throwable $e)
catch (Throwable)
{
dump($newRecord);
}

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace App\Types;
@ -9,7 +9,7 @@ use App\ValueObject\Money;
class MoneyType extends Type {
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
return 'MONEY';
}

View File

@ -2,8 +2,9 @@
namespace App\ValueObject;
class Money {
private float $value;
use Stringable;
class Money implements Stringable {
private readonly float $value;
public function __construct($value)
{