More refactoring

This commit is contained in:
Timothy Warren 2022-02-18 11:34:25 -05:00
parent 41caca2722
commit ea2ec447e6
21 changed files with 224 additions and 305 deletions

View File

@ -22,10 +22,13 @@ 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.
*/
@ -56,6 +59,7 @@ class CameraController extends AbstractController
'working' => $working,
]);
}
/**
* Creates a new camera entity.
*/
@ -64,6 +68,7 @@ class CameraController extends AbstractController
{
return $this->itemCreate($request, 'camera/new.html.twig', 'camera', 'camera_show');
}
/**
* Finds and displays a camera entity.
*/
@ -72,6 +77,7 @@ class CameraController extends AbstractController
{
return $this->itemView($camera, 'camera/show.html.twig', 'camera');
}
/**
* Displays a form to edit an existing camera entity.
*
@ -82,6 +88,7 @@ class CameraController extends AbstractController
{
return $this->itemUpdate($request, $camera, 'camera/edit.html.twig', 'camera', 'camera_show');
}
/**
* Deletes a camera entity.
*
@ -92,6 +99,7 @@ class CameraController extends AbstractController
{
return $this->itemDelete($request, $camera, 'camera_index');
}
/**
* Moves a camera to the previouslyOwned table
*
@ -103,6 +111,7 @@ class CameraController extends AbstractController
{
return $this->itemDeacquire($request, $camera, 'previously-owned-camera_index');
}
/**
* Creates a form to delete a camera entity.
*
@ -114,6 +123,7 @@ class CameraController extends AbstractController
{
return $this->buildForm($camera, 'camera_delete', 'DELETE');
}
/**
* Creates a form to move
*
@ -123,10 +133,12 @@ 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

@ -2,72 +2,80 @@
namespace App\Controller;
use Symfony\Component\Form\Form;
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(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(path: '/', name: 'camera-type_index', methods: ['GET'])]
public function indexAction()
public function indexAction(): Response
{
return $this->itemListView('cameratype/index.html.twig', 'cameraTypes', [
'type' => 'ASC',
]);
}
/**
* Creates a new cameraType entity.
*/
#[Route(path: '/new', name: 'camera-type_new', methods: ['GET', 'POST'])]
public function newAction(Request $request)
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(path: '/{id}', name: 'camera-type_show', methods: ['GET'])]
public function showAction(CameraType $cameraType)
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(path: '/{id}/edit', name: 'camera-type_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, CameraType $cameraType)
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(path: '/{id}', name: 'camera-type_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, CameraType $cameraType)
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 Form The form
*/
private function createDeleteForm(CameraType $cameraType)
private function createDeleteForm(CameraType $cameraType): FormInterface
{
return $this->buildForm($cameraType, 'camera-type_delete', 'DELETE');
}

View File

@ -21,10 +21,13 @@ 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.
*/
@ -53,6 +56,7 @@ class FilmController extends AbstractController
'films' => $notInCamera,
]);
}
/**
* Creates a new film entity.
*/
@ -61,6 +65,7 @@ class FilmController extends AbstractController
{
return $this->itemCreate($request, 'film/new.html.twig', 'film', 'film_show');
}
/**
* Finds and displays a film entity.
*/
@ -69,6 +74,7 @@ class FilmController extends AbstractController
{
return $this->itemView($film, 'film/show.html.twig', 'film');
}
/**
* Displays a form to edit an existing film entity.
*
@ -79,6 +85,7 @@ class FilmController extends AbstractController
{
return $this->itemUpdate($request, $film, 'film/edit.html.twig', 'film', 'film_show');
}
/**
* Deletes a film entity.
*
@ -89,6 +96,7 @@ class FilmController extends AbstractController
{
return $this->itemDelete($request, $film, 'film_index');
}
/**
* Creates a form to delete a film entity.
*

View File

@ -2,10 +2,13 @@
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;
@ -16,56 +19,64 @@ use Symfony\Component\HttpFoundation\Request;
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(path: '/', name: 'flash_index', methods: ['GET'])]
public function indexAction()
public function indexAction(): Response
{
return $this->itemListView('flash/index.html.twig', 'flashes');
}
/**
* Creates a new flash entity.
*/
#[Route(path: '/new', name: 'flash_new', methods: ['GET', 'POST'])]
public function newAction(Request $request)
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(path: '/{id}', name: 'flash_show', methods: ['GET'])]
public function showAction(Flash $flash)
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(path: '/{id}/edit', name: 'flash_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, Flash $flash)
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(path: '/{id}', name: 'flash_delete', methods: ['DELETE'])]
public function deleteAction(Request $request, Flash $flash)
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 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

@ -18,10 +18,13 @@ 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.
*/
@ -52,6 +55,7 @@ class LensesController extends AbstractController
'lenses' => $receivedItems,
]);
}
/**
* Creates a new lens entity.
*/
@ -60,6 +64,7 @@ class LensesController extends AbstractController
{
return $this->itemCreate($request, 'lenses/new.html.twig', 'lense', 'lens_show');
}
/**
* Finds and displays a lens entity.
*/
@ -68,6 +73,7 @@ class LensesController extends AbstractController
{
return $this->itemView($lens, 'lenses/show.html.twig', 'lense');
}
/**
* Displays a form to edit an existing lens entity.
*/
@ -76,6 +82,7 @@ class LensesController extends AbstractController
{
return $this->itemUpdate($request, $lens, 'lenses/edit.html.twig', 'lense', 'lens_show');
}
/**
* Moves a camera to the previouslyOwned table
*
@ -87,6 +94,7 @@ class LensesController extends AbstractController
{
return $this->itemDeacquire($request, $lens, 'previously-owned-lens_index');
}
/**
* Deletes a lens entity.
*/
@ -95,6 +103,7 @@ class LensesController extends AbstractController
{
return $this->itemDelete($request, $lens, 'lens_index');
}
/**
* Creates a form to delete a lens entity.
*
@ -106,6 +115,7 @@ class LensesController extends AbstractController
{
return $this->buildForm($lens, 'lens_delete', 'DELETE');
}
/**
* Creates a form to move
*

View File

@ -20,7 +20,9 @@ class PreviouslyOwnedCameraController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = PreviouslyOwnedCamera::class;
protected const FORM = PreviouslyOwnedCameraType::class;
/**
* Lists all previouslyOwnedCamera entities.
*
@ -35,6 +37,7 @@ class PreviouslyOwnedCameraController extends AbstractController
'model' => 'ASC',
]);
}
/**
* Finds and displays a previouslyOwnedCamera entity.
*/
@ -43,6 +46,7 @@ class PreviouslyOwnedCameraController extends AbstractController
{
return $this->itemView($previouslyOwnedCamera, 'previouslyownedcamera/show.html.twig', 'previouslyOwnedCamera');
}
/**
* Displays a form to edit an existing previouslyOwnedCamera entity.
*
@ -53,6 +57,7 @@ class PreviouslyOwnedCameraController extends AbstractController
{
return $this->itemUpdate($request, $previouslyOwnedCamera, 'previouslyownedcamera/edit.html.twig', 'previouslyOwnedCamera', 'previously-owned-camera_show');
}
/**
* Moves a camera to the previouslyOwned table
*
@ -66,6 +71,7 @@ class PreviouslyOwnedCameraController extends AbstractController
{
return $this->itemReacquire($request, $camera, 'camera_index');
}
/**
* Creates a form to move
*

View File

@ -4,7 +4,10 @@ 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;
@ -15,16 +18,24 @@ use Symfony\Component\HttpFoundation\Request;
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(path: '/', name: 'previously-owned-flash_index', methods: ['GET'])]
public function indexAction()
public function indexAction(): Response
{
return $this->itemListView('previouslyownedflash/index.html.twig', 'previouslyOwnedFlashes');
}
/**
* Creates a new previouslyOwnedFlash entity.
*/
@ -33,19 +44,21 @@ class PreviouslyOwnedFlashController extends AbstractController
{
return $this->itemCreate($request, 'previouslyownedflash/new.html.twig', 'previouslyOwnedFlash', 'previously-owned-flash_show');
}
/**
* Finds and displays a previouslyOwnedFlash entity.
*/
#[Route(path: '/{id}', name: 'previously-owned-flash_show', methods: ['GET'])]
public function showAction(PreviouslyOwnedFlash $previouslyOwnedFlash)
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(path: '/{id}/edit', name: 'previously-owned-flash_edit', methods: ['GET', 'POST'])]
public function editAction(Request $request, PreviouslyOwnedFlash $previouslyOwnedFlash)
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

@ -13,7 +13,9 @@ class PreviouslyOwnedLensesController extends AbstractController
{
use FormControllerTrait;
protected const ENTITY = PreviouslyOwnedLenses::class;
protected const FORM = PreviouslyOwnedLensesType::class;
/**
* Lists all previouslyOwnedLense entities.
*/
@ -28,6 +30,7 @@ class PreviouslyOwnedLensesController extends AbstractController
'maxFStop' => 'ASC',
]);
}
/**
* Finds and displays a previouslyOwnedLense entity.
*/
@ -36,6 +39,7 @@ class PreviouslyOwnedLensesController extends AbstractController
{
return $this->itemView($previouslyOwnedLens, 'previouslyownedlenses/show.html.twig', 'previouslyOwnedLense');
}
/**
* Displays a form to edit an existing previouslyOwnedLense entity.
*/

View File

@ -15,95 +15,51 @@ trait CameraTrait
{
use PurchasePriceTrait;
/**
* @var CameraType
*/
#[ORM\ManyToOne(targetEntity: 'CameraType')]
#[ORM\JoinColumn(name: 'type_id', referencedColumnName: 'id')]private readonly ?CameraType $type;
#[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 readonly 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 readonly 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 readonly 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 readonly 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)]
private string $cropFactor = '1.0';
/**
* @var boolean
*/
#[ORM\Column(name: 'is_working', type: 'boolean', nullable: false)]private readonly 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 readonly ?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 readonly 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)]
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 readonly ?string $batteryType;
/**
* @var string
*/
#[ORM\Column(name: 'film_format', type: 'string', nullable: true)]
private ?string $filmFormat = '135';
/**
* @var boolean
*/
#[ORM\Column(name: 'received', type: 'boolean', nullable: true)]
private ?bool $received = FALSE;
/**
* Get id
*/
public function getId(): int
{
return $this->id;
}
/**
* Set type
*
*
*/
public function setType(CameraType $type = null): self
{
$this->type = $type;
@ -111,21 +67,11 @@ trait CameraTrait
return $this;
}
/**
* Get type
*
* @return CameraType
*/
public function getType(): ?CameraType
public function getType(): CameraType
{
return $this->type;
}
/**
* Set brand
*
*
*/
public function setBrand(string $brand): self
{
$this->brand = $brand;
@ -133,21 +79,11 @@ trait CameraTrait
return $this;
}
/**
* Get brand
*
* @return string
*/
public function getBrand(): ?string
public function getBrand(): string
{
return $this->brand;
}
/**
* Set mount
*
*
*/
public function setMount(string $mount): self
{
$this->mount = $mount;
@ -155,21 +91,11 @@ trait CameraTrait
return $this;
}
/**
* Get mount
*
* @return string
*/
public function getMount(): ?string
public function getMount(): string
{
return $this->mount;
}
/**
* Set model
*
*
*/
public function setModel(string $model): self
{
$this->model = $model;
@ -177,21 +103,11 @@ trait CameraTrait
return $this;
}
/**
* Get model
*
* @return string
*/
public function getModel(): ?string
public function getModel(): string
{
return $this->model;
}
/**
* Set isDigital
*
*
*/
public function setIsDigital(bool $isDigital): self
{
$this->isDigital = $isDigital;
@ -199,21 +115,11 @@ trait CameraTrait
return $this;
}
/**
* Get isDigital
*
* @return boolean
*/
public function getIsDigital(): ?bool
public function getIsDigital(): bool
{
return $this->isDigital;
}
/**
* Set cropFactor
*
*
*/
public function setCropFactor(string $cropFactor): self
{
$this->cropFactor = $cropFactor;
@ -221,19 +127,11 @@ trait CameraTrait
return $this;
}
/**
* Get cropFactor
*/
public function getCropFactor(): string
{
return $this->cropFactor;
}
/**
* Set isWorking
*
*
*/
public function setIsWorking(bool $isWorking): self
{
$this->isWorking = $isWorking;
@ -241,135 +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
*/
public function setNotes($notes): self
public function setNotes(string $notes): self
{
$this->notes = $notes;
return $this;
}
/**
* Get notes
*/
public function getNotes(): string
{
return $this->notes ?? '';
}
/**
* Set serial
*
* @param string $serial
*/
public function setSerial($serial): self
public function setSerial(string $serial): self
{
$this->serial = $serial;
return $this;
}
/**
* Get serial
*/
public function getSerial(): string
{
return $this->serial ?? '';
}
/**
* Set formerlyOwned
*
* @param boolean $formerlyOwned
*/
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
*/
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
*/
public function setFilmFormat($filmFormat): self
public function setFilmFormat(string $filmFormat): self
{
$this->filmFormat = $filmFormat;
return $this;
}
/**
* Get filmFormat
*/
public function getFilmFormat(): string
{
return $this->filmFormat;
return $this->filmFormat ?? '';
}
/**
* Set received
*
* @param boolean $received
*/
public function setReceived($received): self
public function setReceived(bool $received): self
{
$this->received = $received;
return $this;
}
/**
* Get received
*/
public function getReceived(): bool
{
return $this->received;

View File

@ -17,16 +17,19 @@ class CameraType implements Stringable
#[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)]
private string $type;
/**
* @var string
*/
#[ORM\Column(name: 'description', type: 'text', nullable: true)]
private ?string $description = null;
/**
* Value for serialization
*/
@ -34,6 +37,7 @@ class CameraType implements Stringable
{
return $this->type;
}
/**
* Get id
*/
@ -41,6 +45,7 @@ class CameraType implements Stringable
{
return $this->id;
}
/**
* Set type
*
@ -52,6 +57,7 @@ class CameraType implements Stringable
return $this;
}
/**
* Set description
*
@ -63,6 +69,7 @@ class CameraType implements Stringable
return $this;
}
/**
* Get type
*
@ -72,6 +79,7 @@ class CameraType implements Stringable
{
return $this->type;
}
/**
* Get description
*

View File

@ -15,75 +15,90 @@ class Film
#[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)]
private string $brand;
/**
* @var string
*/
#[ORM\Column(name: 'product_line', type: 'string', nullable: true)]
private ?string $productLine = null;
/**
* @var string
*/
#[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 = null;
/**
* @var int
*/
#[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)]
private int $filmSpeedDin;
/**
* @var string
*/
#[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'])]
private string $filmBase = 'Cellulose Triacetate';
/**
* @var int
*/
#[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])]
private int $rollsInCamera = 0;
/**
* @var int
*/
#[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'])]
private string $chemistry = 'C-41';
/**
* @var string
*/
#[ORM\Column(name: 'notes', type: 'text', nullable: true)]
private ?string $notes = null;
public function getId(): int
{
return $this->id;
}
/**
* @return string
*/
@ -91,11 +106,13 @@ class Film
{
return $this->brand;
}
public function setBrand(string $brand): self
{
$this->brand = $brand;
return $this;
}
/**
* @return string
*/
@ -103,6 +120,7 @@ class Film
{
return $this->productLine;
}
/**
* @param string $productLine
*/
@ -111,6 +129,7 @@ class Film
$this->productLine = $productLine;
return $this;
}
/**
* @return string
*/
@ -118,11 +137,13 @@ class Film
{
return $this->filmName;
}
public function setFilmName(string $filmName): self
{
$this->filmName = $filmName;
return $this;
}
/**
* @return string
*/
@ -130,11 +151,13 @@ class Film
{
return $this->filmAlias;
}
public function setFilmAlias(string $filmAlias): self
{
$this->filmAlias = $filmAlias;
return $this;
}
/**
* @return int
*/
@ -142,11 +165,13 @@ class Film
{
return $this->filmSpeedAsa;
}
public function setFilmSpeedAsa(int $filmSpeedAsa): self
{
$this->filmSpeedAsa = $filmSpeedAsa;
return $this;
}
/**
* @return int
*/
@ -154,11 +179,13 @@ class Film
{
return $this->filmSpeedDin;
}
public function setFilmSpeedDin(int $filmSpeedDin): self
{
$this->filmSpeedDin = $filmSpeedDin;
return $this;
}
/**
* @return string
*/
@ -166,11 +193,13 @@ class Film
{
return $this->filmFormat;
}
public function setFilmFormat(string $filmFormat): self
{
$this->filmFormat = $filmFormat;
return $this;
}
/**
* @return string
*/
@ -178,11 +207,13 @@ class Film
{
return $this->filmBase;
}
public function setFilmBase(string $filmBase): self
{
$this->filmBase = $filmBase;
return $this;
}
/**
* @return int
*/
@ -190,11 +221,13 @@ class Film
{
return $this->unusedRolls;
}
public function setUnusedRolls(int $unusedRolls): self
{
$this->unusedRolls = $unusedRolls;
return $this;
}
/**
* @return int
*/
@ -202,11 +235,13 @@ class Film
{
return $this->rollsInCamera;
}
public function setRollsInCamera(int $rollsInCamera): self
{
$this->rollsInCamera = $rollsInCamera;
return $this;
}
/**
* @return int
*/
@ -214,11 +249,13 @@ class Film
{
return $this->developedRolls;
}
public function setDevelopedRolls(int $developedRolls): self
{
$this->developedRolls = $developedRolls;
return $this;
}
/**
* @return string
*/
@ -226,11 +263,13 @@ class Film
{
return $this->chemistry;
}
public function setChemistry(string $chemistry): self
{
$this->chemistry = $chemistry;
return $this;
}
/**
* @return string
*/
@ -238,6 +277,7 @@ class Film
{
return $this->notes;
}
public function setNotes(string $notes): self
{
$this->notes = $notes;

View File

@ -12,16 +12,19 @@ class FilmFormat
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
/**
* @var int
*/
#[ORM\Column(name: 'number_id', type: 'integer')]
private int $numberId;
/**
* @var string
*/
#[ORM\Column(name: 'name', type: 'string')]
private string $name;
/**
* @return int
*/
@ -29,6 +32,7 @@ class FilmFormat
{
return $this->id;
}
/**
* @return int
*/
@ -36,11 +40,13 @@ class FilmFormat
{
return $this->numberId;
}
public function setNumberId(int $numberId): self
{
$this->numberId = $numberId;
return $this;
}
/**
* @return string
*/
@ -48,6 +54,7 @@ class FilmFormat
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;

View File

@ -12,19 +12,18 @@ use Doctrine\ORM\Mapping as ORM;
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;
private int $id;
/**
* @var boolean
*/
#[ORM\Column(name: 'received', type: 'boolean', nullable: false, options: ['default' => false])]
private bool $received = false;
/**
* @var boolean
*/

View File

@ -8,75 +8,39 @@ trait FlashTrait
{
use PurchasePriceTrait;
/**
* @var string
*/
#[ORM\Column(name: 'brand', type: 'string', nullable: false)]private readonly 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 readonly 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)]
private bool $isAutoFlash = false;
/**
* @var boolean
*/
#[ORM\Column(name: 'is_ttl', type: 'boolean', nullable: false)]
private bool $isTtl = false;
/**
* @var string
*/
#[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)]
private bool $isPTtl = false;
/**
* @var string
*/
#[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 readonly 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 readonly ?string $purchasePrice;
/**
* @var string
*/
#[ORM\Column(name: 'batteries', type: 'string', nullable: false)]
private string $batteries = '4x AA';
/**
* @var string
*/
#[ORM\Column(name: 'notes', type: 'text', nullable: true)]private readonly ?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 readonly ?string $serial;
#[ORM\Column(name: 'serial', type: 'string', nullable: true)]
private readonly ?string $serial;
/**
* Get id
*/
public function getId(): int
{
return $this->id;
@ -85,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;

View File

@ -62,12 +62,6 @@ trait LensTrait
#[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 readonly ?string $purchasePrice;
/**
* @var string
*/

View File

@ -18,8 +18,10 @@ class Lenses
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'camera.lenses_id_seq', allocationSize: 1, initialValue: 1)]
private int $id;
#[ORM\Column(name: 'received', type: 'boolean', nullable: false)]
private bool $received = false;
#[ORM\Column(name: 'formerly_owned', type: 'boolean', nullable: false)]
private bool $formerlyOwned = false;
}

View File

@ -12,21 +12,15 @@ use Doctrine\ORM\Mapping as ORM;
class PreviouslyOwnedFlash
{
use FlashTrait;
/**
* @var integer
*/
#[ORM\Column(name: 'id', type: 'integer', nullable: false)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private $id;
/**
* @var boolean
*/
private int $id;
#[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])]
private bool $formerlyOwned = true;
}

View File

@ -17,11 +17,13 @@ class PreviouslyOwnedLenses
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int $id;
/**
* @var boolean
*/
#[ORM\Column(name: 'received', type: 'boolean', nullable: false)]
private bool $received = true;
/**
* @var boolean
*/

View File

@ -2,29 +2,24 @@
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
trait PurchasePriceTrait
{
/**
* Set purchasePrice
*
* @param string $purchasePrice
*/
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

@ -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';
}