Refactor common CRUD traits

This commit is contained in:
Timothy Warren 2023-07-21 10:23:16 -04:00
parent f6e00fbdb7
commit 80bb63fdd6
33 changed files with 1570 additions and 1436 deletions

View File

@ -2,30 +2,30 @@
"type": "project", "type": "project",
"license": "proprietary", "license": "proprietary",
"require": { "require": {
"php": "^8.1.0", "php": ">=8.2",
"composer/package-versions-deprecated": "1.11.99.5", "composer/package-versions-deprecated": "1.11.99.5",
"doctrine/doctrine-bundle": "^2", "doctrine/doctrine-bundle": "^2.8.2",
"doctrine/doctrine-migrations-bundle": "^3.2.2", "doctrine/doctrine-migrations-bundle": "^3.2.2",
"doctrine/orm": "^2", "doctrine/orm": "^2.14.1",
"sensio/framework-extra-bundle": "^6.2.6", "sensio/framework-extra-bundle": "^6.2.9",
"symfony/form": "^6.0.3", "symfony/form": "^6.2.5",
"symfony/maker-bundle": "^1.0", "symfony/maker-bundle": "^1.48",
"symfony/monolog-bundle": "^3.0", "symfony/monolog-bundle": "^3.8",
"symfony/security-bundle": "^6.1", "symfony/security-bundle": "^6.2.6",
"symfony/security-csrf": "^6.1", "symfony/security-csrf": "^6.2.5",
"symfony/translation": "^6.0.3", "symfony/translation": "^6.2.5",
"symfony/twig-bundle": "^6.0", "symfony/twig-bundle": "^6.2.5",
"symfony/validator": "^6.0.3", "symfony/validator": "^6.2.5",
"symfony/yaml": "^6.0.3", "symfony/yaml": "^6.2.5",
"twig/twig": "^2.12|^3.0" "twig/twig": "^2.12|^3.5"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5.28",
"roave/security-advisories": "dev-master", "roave/security-advisories": "dev-master",
"symfony/dotenv": "^6.0.3", "symfony/dotenv": "^6.2.5",
"symfony/flex": "^2.1.6", "symfony/flex": "^2.2.4",
"symfony/stopwatch": "^6.0.3", "symfony/stopwatch": "^6.2.5",
"symfony/web-profiler-bundle": "^6.0" "symfony/web-profiler-bundle": "^6.2.5"
}, },
"config": { "config": {
"preferred-install": { "preferred-install": {

2192
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\BrandCategory; use App\Entity\BrandCategory;
use App\Form\BrandCategoryType; use App\Form\BrandCategoryType;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -14,7 +13,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route('/brand/category')] #[Route('/brand/category')]
class BrandCategoryController extends AbstractController class BrandCategoryController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
protected const ENTITY = BrandCategory::class; protected const ENTITY = BrandCategory::class;
protected const TEMPLATE_PATH = 'brand_category/'; protected const TEMPLATE_PATH = 'brand_category/';

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\Brand; use App\Entity\Brand;
use App\Form\BrandType; use App\Form\BrandType;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{Request, Response}; use Symfony\Component\HttpFoundation\{Request, Response};
@ -13,7 +12,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route('/brand')] #[Route('/brand')]
class BrandController extends AbstractController class BrandController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
protected const ENTITY = Brand::class; protected const ENTITY = Brand::class;
protected const TEMPLATE_PATH = 'brand/'; protected const TEMPLATE_PATH = 'brand/';

View File

@ -4,7 +4,8 @@ namespace App\Controller;
use App\Entity\Camera; use App\Entity\Camera;
use App\Form\CameraType; use App\Form\CameraType;
use App\Traits\{DeleteFormTrait, FormControllerTrait}; use App\Controller\
{DeleteFormTrait};
use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException}; use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException};
use LogicException; use LogicException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -18,7 +19,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route(path: 'camera')] #[Route(path: 'camera')]
class CameraController extends AbstractController class CameraController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
use DeleteFormTrait; use DeleteFormTrait;
protected const ENTITY = Camera::class; protected const ENTITY = Camera::class;

View File

@ -4,7 +4,8 @@ namespace App\Controller;
use App\Entity\CameraType; use App\Entity\CameraType;
use App\Form\CameraTypeType; use App\Form\CameraTypeType;
use App\Traits\{DeleteFormTrait, FormControllerTrait}; use App\Controller\
{DeleteFormTrait};
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
@ -13,7 +14,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route(path: 'camera-type')] #[Route(path: 'camera-type')]
class CameraTypeController extends AbstractController class CameraTypeController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
use DeleteFormTrait; use DeleteFormTrait;
protected const ENTITY = CameraType::class; protected const ENTITY = CameraType::class;

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\Chipset; use App\Entity\Chipset;
use App\Form\ChipsetType; use App\Form\ChipsetType;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -13,7 +12,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route('/chipset')] #[Route('/chipset')]
class ChipsetController extends AbstractController { class ChipsetController extends AbstractController {
use FormControllerTrait; use FormControllerBase;
protected const ENTITY = Chipset::class; protected const ENTITY = Chipset::class;
protected const TEMPLATE_PATH = 'chipset/'; protected const TEMPLATE_PATH = 'chipset/';

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\Cpu; use App\Entity\Cpu;
use App\Form\CpuType; use App\Form\CpuType;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -13,7 +12,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route('/cpu')] #[Route('/cpu')]
class CpuController extends AbstractController { class CpuController extends AbstractController {
use FormControllerTrait; use FormControllerBase;
protected const ENTITY = Cpu::class; protected const ENTITY = Cpu::class;
protected const TEMPLATE_PATH = 'cpu/'; protected const TEMPLATE_PATH = 'cpu/';

View File

@ -1,6 +1,6 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace App\Traits; namespace App\Controller;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;

View File

@ -4,7 +4,8 @@ namespace App\Controller;
use App\Entity\Film; use App\Entity\Film;
use App\Form\FilmType; use App\Form\FilmType;
use App\Traits\{DeleteFormTrait, FormControllerTrait}; use App\Controller\
{DeleteFormTrait};
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use LogicException; use LogicException;
@ -18,7 +19,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route(path: 'film')] #[Route(path: 'film')]
class FilmController extends AbstractController class FilmController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
use DeleteFormTrait; use DeleteFormTrait;
protected const ENTITY = Film::class; protected const ENTITY = Film::class;

View File

@ -4,7 +4,8 @@ namespace App\Controller;
use App\Entity\Flash; use App\Entity\Flash;
use App\Form\FlashType; use App\Form\FlashType;
use App\Traits\{DeleteFormTrait, FormControllerTrait}; use App\Controller\
{DeleteFormTrait};
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
@ -16,7 +17,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route(path: 'flash')] #[Route(path: 'flash')]
class FlashController extends AbstractController class FlashController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
use DeleteFormTrait; use DeleteFormTrait;
protected const ENTITY = Flash::class; protected const ENTITY = Flash::class;

View File

@ -1,14 +1,16 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
namespace App\Traits; namespace App\Controller;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
trait FormControllerTrait trait FormControllerBase
{ {
private readonly EntityManagerInterface $entityManager; public function __construct(private readonly EntityManagerInterface $entityManager)
{
}
/** /**
* Create a form generator * Create a form generator

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\Fpu; use App\Entity\Fpu;
use App\Form\FpuType; use App\Form\FpuType;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -14,7 +13,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route('/fpu')] #[Route('/fpu')]
class FpuController extends AbstractController class FpuController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
protected const ENTITY = Fpu::class; protected const ENTITY = Fpu::class;
protected const TEMPLATE_PATH = 'fpu/'; protected const TEMPLATE_PATH = 'fpu/';

View File

@ -5,7 +5,6 @@ namespace App\Controller;
use App\Entity\Gpu; use App\Entity\Gpu;
use App\Enum\SlotKey; use App\Enum\SlotKey;
use App\Form\GpuType; use App\Form\GpuType;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{Request, Response}; use Symfony\Component\HttpFoundation\{Request, Response};
@ -14,7 +13,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route('/gpu')] #[Route('/gpu')]
class GpuController extends AbstractController class GpuController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
protected const ENTITY = Gpu::class; protected const ENTITY = Gpu::class;
protected const TEMPLATE_PATH = 'gpu/'; protected const TEMPLATE_PATH = 'gpu/';

View File

@ -4,7 +4,6 @@ namespace App\Controller;
use App\Entity\GpuCore; use App\Entity\GpuCore;
use App\Form\GPUCoreType; use App\Form\GPUCoreType;
use App\Traits\FormControllerTrait;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{Request, Response}; use Symfony\Component\HttpFoundation\{Request, Response};
@ -13,7 +12,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route('/gpu-core')] #[Route('/gpu-core')]
class GpuCoreController extends AbstractController class GpuCoreController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
protected const ENTITY = GpuCore::class; protected const ENTITY = GpuCore::class;
protected const TEMPLATE_PATH = 'gpu_core/'; protected const TEMPLATE_PATH = 'gpu_core/';

View File

@ -4,7 +4,8 @@ namespace App\Controller;
use App\Entity\Lenses; use App\Entity\Lenses;
use App\Form\LensesType; use App\Form\LensesType;
use App\Traits\{DeleteFormTrait, FormControllerTrait}; use App\Controller\
{DeleteFormTrait};
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
@ -17,7 +18,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route(path: 'lens')] #[Route(path: 'lens')]
class LensesController extends AbstractController class LensesController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
use DeleteFormTrait; use DeleteFormTrait;
protected const ENTITY = Lenses::class; protected const ENTITY = Lenses::class;

View File

@ -4,7 +4,7 @@ namespace App\Controller;
use App\Entity\PreviouslyOwnedCamera; use App\Entity\PreviouslyOwnedCamera;
use App\Form\PreviouslyOwnedCameraType; use App\Form\PreviouslyOwnedCameraType;
use App\Traits\FormControllerTrait; use App\Controller\FormControllerBase;
use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException}; use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException};
use LogicException; use LogicException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@ -19,7 +19,7 @@ use UnexpectedValueException;
#[Route(path: 'previously-owned-camera')] #[Route(path: 'previously-owned-camera')]
class PreviouslyOwnedCameraController extends AbstractController class PreviouslyOwnedCameraController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
protected const ENTITY = PreviouslyOwnedCamera::class; protected const ENTITY = PreviouslyOwnedCamera::class;
protected const TEMPLATE_PATH = 'previouslyownedcamera/'; protected const TEMPLATE_PATH = 'previouslyownedcamera/';

View File

@ -4,7 +4,7 @@ namespace App\Controller;
use App\Entity\PreviouslyOwnedFlash; use App\Entity\PreviouslyOwnedFlash;
use App\Form\PreviouslyOwnedFlashType; use App\Form\PreviouslyOwnedFlashType;
use App\Traits\FormControllerTrait; use App\Controller\FormControllerBase;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
@ -16,7 +16,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route(path: 'previously-owned-flash')] #[Route(path: 'previously-owned-flash')]
class PreviouslyOwnedFlashController extends AbstractController class PreviouslyOwnedFlashController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
protected const ENTITY = PreviouslyOwnedFlash::class; protected const ENTITY = PreviouslyOwnedFlash::class;
protected const ROUTE_PREFIX = 'previously-owned-flash_'; protected const ROUTE_PREFIX = 'previously-owned-flash_';

View File

@ -4,7 +4,7 @@ namespace App\Controller;
use App\Entity\PreviouslyOwnedLenses; use App\Entity\PreviouslyOwnedLenses;
use App\Form\PreviouslyOwnedLensesType; use App\Form\PreviouslyOwnedLensesType;
use App\Traits\FormControllerTrait; use App\Controller\FormControllerBase;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response}; use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
@ -13,7 +13,7 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route(path: 'previously-owned-lens')] #[Route(path: 'previously-owned-lens')]
class PreviouslyOwnedLensesController extends AbstractController class PreviouslyOwnedLensesController extends AbstractController
{ {
use FormControllerTrait; use FormControllerBase;
protected const ENTITY = PreviouslyOwnedLenses::class; protected const ENTITY = PreviouslyOwnedLenses::class;
protected const TEMPLATE_PATH = 'previouslyownedlenses/'; protected const TEMPLATE_PATH = 'previouslyownedlenses/';

View File

@ -3,8 +3,7 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Socket; use App\Entity\Socket;
use App\Form\SocketType; use App\Form\SocketTypeForm;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -13,72 +12,40 @@ use Symfony\Component\Routing\Annotation\Route;
#[Route('/socket')] #[Route('/socket')]
class SocketController extends AbstractController class SocketController extends AbstractController
{ {
#[Route('/', name: 'socket_index', methods: ['GET'])] use FormControllerBase;
public function index(EntityManagerInterface $entityManager): Response
{
$sockets = $entityManager
->getRepository(Socket::class)
->findAll();
return $this->render('socket/index.html.twig', [ protected const ENTITY = Socket::class;
'sockets' => $sockets, protected const ROUTE_PREFIX = 'socket_';
]); protected const TEMPLATE_PATH = 'socket/';
protected const FORM = SocketTypeForm::class;
#[Route('/', name: 'socket_index', methods: ['GET'])]
public function index(): Response
{
return $this->itemListView('sockets');
} }
#[Route('/new', name: 'socket_new', methods: ['GET', 'POST'])] #[Route('/new', name: 'socket_new', methods: ['GET', 'POST'])]
public function new(Request $request, EntityManagerInterface $entityManager): Response public function new(Request $request): Response
{ {
$socket = new Socket(); return $this->itemCreate($request, 'sockets');
$form = $this->createForm(SocketType::class, $socket);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->persist($socket);
$entityManager->flush();
return $this->redirectToRoute('socket_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('socket/new.html.twig', [
'socket' => $socket,
'form' => $form,
]);
} }
#[Route('/{id}', name: 'socket_show', methods: ['GET'])] #[Route('/{id}', name: 'socket_show', methods: ['GET'])]
public function show(Socket $socket): Response public function show(Socket $socket): Response
{ {
return $this->render('socket/show.html.twig', [ return $this->itemView($socket, 'socket');
'socket' => $socket,
]);
} }
#[Route('/{id}/edit', name: 'socket_edit', methods: ['GET', 'POST'])] #[Route('/{id}/edit', name: 'socket_edit', methods: ['GET', 'POST'])]
public function edit(Request $request, Socket $socket, EntityManagerInterface $entityManager): Response public function edit(Request $request, Socket $socket): Response
{ {
$form = $this->createForm(SocketType::class, $socket); return $this->itemUpdate($request, $socket, 'socket');
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$entityManager->flush();
return $this->redirectToRoute('socket_index', [], Response::HTTP_SEE_OTHER);
}
return $this->renderForm('socket/edit.html.twig', [
'socket' => $socket,
'form' => $form,
]);
} }
#[Route('/{id}', name: 'socket_delete', methods: ['POST'])] #[Route('/{id}', name: 'socket_delete', methods: ['POST'])]
public function delete(Request $request, Socket $socket, EntityManagerInterface $entityManager): Response public function delete(Request $request, Socket $socket): Response
{ {
if ($this->isCsrfTokenValid('delete'.$socket->getId(), $request->request->get('_token'))) { return $this->deleteCSRF($request, $socket);
$entityManager->remove($socket);
$entityManager->flush();
}
return $this->redirectToRoute('socket_index', [], Response::HTTP_SEE_OTHER);
} }
} }

View File

@ -13,7 +13,7 @@ use Doctrine\ORM\Mapping as ORM;
class Camera class Camera
{ {
use GetSet; use GetSet;
use CameraTrait; use CameraBase;
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
#[ORM\Id] #[ORM\Id]

View File

@ -9,7 +9,7 @@ use Doctrine\ORM\Mapping as ORM;
* *
* Shared columns for camera, and previously_owned_camera tables * Shared columns for camera, and previously_owned_camera tables
*/ */
trait CameraTrait trait CameraBase
{ {
use PurchasePrice; use PurchasePrice;

View File

@ -12,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
class Flash class Flash
{ {
use GetSet; use GetSet;
use FlashTrait; use FlashBase;
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
#[ORM\Id] #[ORM\Id]

View File

@ -4,7 +4,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
trait FlashTrait trait FlashBase
{ {
use PurchasePrice; use PurchasePrice;

View File

@ -13,7 +13,7 @@ use Doctrine\ORM\Mapping as ORM;
class PreviouslyOwnedCamera class PreviouslyOwnedCamera
{ {
use GetSet; use GetSet;
use CameraTrait; use CameraBase;
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
#[ORM\Id] #[ORM\Id]

View File

@ -12,7 +12,7 @@ use Doctrine\ORM\Mapping as ORM;
class PreviouslyOwnedFlash class PreviouslyOwnedFlash
{ {
use GetSet; use GetSet;
use FlashTrait; use FlashBase;
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)] #[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
#[ORM\Id] #[ORM\Id]

View File

@ -2,7 +2,7 @@
namespace App\Entity; namespace App\Entity;
use App\Enum\SocketTypeEnum; use App\Enum\SocketType;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -37,9 +37,9 @@ class Socket {
#[ORM\Column( #[ORM\Column(
name: 'socket_type', name: 'socket_type',
type: 'string', type: 'string',
enumType: SocketTypeEnum::class, enumType: SocketType::class,
)] )]
private SocketTypeEnum $type = SocketTypeEnum::PIN_GRID_ARRAY; private SocketType $type = SocketType::PIN_GRID_ARRAY;
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
namespace App\Enum; namespace App\Enum;
enum SocketTypeEnum: string { enum SocketType: string {
case DUAL_INLINE_PACKAGE = 'DIP'; case DUAL_INLINE_PACKAGE = 'DIP';
case LEAD_LESS_CHIP_CARRIER = 'LLCC'; case LEAD_LESS_CHIP_CARRIER = 'LLCC';
case PLASTIC_LEADED_CHIP_CARRIER = 'PLCC'; case PLASTIC_LEADED_CHIP_CARRIER = 'PLCC';

View File

@ -3,13 +3,13 @@
namespace App\Form; namespace App\Form;
use App\Entity\Socket; use App\Entity\Socket;
use App\Enum\SocketTypeEnum; use App\Enum\SocketType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EnumType; use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
class SocketType extends AbstractType class SocketTypeForm extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
@ -18,7 +18,7 @@ class SocketType extends AbstractType
->add('otherName') ->add('otherName')
->add('pinCount') ->add('pinCount')
->add('type', EnumType::class,[ ->add('type', EnumType::class,[
'class' => SocketTypeEnum::class, 'class' => SocketType::class,
]) ])
; ;
} }

View File

@ -11,7 +11,6 @@
namespace App\Maker; namespace App\Maker;
use App\Traits\FormControllerTrait;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Inflector\Inflector; use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\InflectorFactory; use Doctrine\Inflector\InflectorFactory;
@ -165,7 +164,6 @@ final class MakeCollectionCrud extends AbstractMaker
Request::class, Request::class,
Response::class, Response::class,
Route::class, Route::class,
FormControllerTrait::class,
]); ]);
$generator->generateController( $generator->generateController(

View File

@ -1,6 +1,6 @@
{ {
"require": { "require": {
"friendsofphp/php-cs-fixer": "^3.6", "friendsofphp/php-cs-fixer": "^3.6",
"rector/rector": "^0.12.16" "rector/rector": "^0.17.6"
} }
} }

608
tools/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -135,6 +135,7 @@ return [
'Other' => 'Other', 'Other' => 'Other',
'Others' => 'Others', 'Others' => 'Others',
'P ttl type' => 'P-TTL Type', 'P ttl type' => 'P-TTL Type',
'Parts' => 'Parts',
'Part number' => 'Part Number', 'Part number' => 'Part Number',
'PCI 32-bit' => 'PCI 32-bit', 'PCI 32-bit' => 'PCI 32-bit',
'PCI 33' => 'PCI 33', 'PCI 33' => 'PCI 33',