Fix code formatting
This commit is contained in:
parent
41d19ad84b
commit
fb296c1034
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
@ -7,67 +7,52 @@ use App\Form\BrandType;
|
|||||||
use App\Traits\FormControllerTrait;
|
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, Response};
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
#[Route('/brand')]
|
#[Route('/brand')]
|
||||||
class BrandController extends AbstractController
|
class BrandController extends AbstractController
|
||||||
{
|
{
|
||||||
use FormControllerTrait;
|
use FormControllerTrait;
|
||||||
|
|
||||||
protected const ENTITY = Brand::class;
|
protected const ENTITY = Brand::class;
|
||||||
protected const TEMPLATE_PATH = 'brand/';
|
protected const TEMPLATE_PATH = 'brand/';
|
||||||
protected const ROUTE_PREFIX = 'brand_';
|
protected const ROUTE_PREFIX = 'brand_';
|
||||||
protected const FORM = BrandType::class;
|
protected const FORM = BrandType::class;
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/', name: 'brand_index', methods: ['GET'])]
|
#[Route('/', name: 'brand_index', methods: ['GET'])]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
return $this->itemListView('brands', [
|
return $this->itemListView('brands', [
|
||||||
'name' => 'asc'
|
'name' => 'asc',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/new', name: 'brand_new', methods: ['GET', 'POST'])]
|
#[Route('/new', name: 'brand_new', methods: ['GET', 'POST'])]
|
||||||
public function new(Request $request): Response
|
public function new(Request $request): Response
|
||||||
{
|
{
|
||||||
return $this->itemCreate($request, 'brand');
|
return $this->itemCreate($request, 'brand');
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/{id}', name: 'brand_show', methods: ['GET'])]
|
#[Route('/{id}', name: 'brand_show', methods: ['GET'])]
|
||||||
public function show(Brand $brand): Response
|
public function show(Brand $brand): Response
|
||||||
{
|
{
|
||||||
return $this->itemView($brand, 'brand');
|
return $this->itemView($brand, 'brand');
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/{id}/edit', name: 'brand_edit', methods: ['GET', 'POST'])]
|
#[Route('/{id}/edit', name: 'brand_edit', methods: ['GET', 'POST'])]
|
||||||
public function edit(Request $request, Brand $brand): Response
|
public function edit(Request $request, Brand $brand): Response
|
||||||
{
|
{
|
||||||
return $this->itemUpdate($request, $brand, 'brand');
|
return $this->itemUpdate($request, $brand, 'brand');
|
||||||
//
|
|
||||||
// $form = $this->createForm(BrandType::class, $brand);
|
|
||||||
// $form->handleRequest($request);
|
|
||||||
//
|
|
||||||
// if ($form->isSubmitted() && $form->isValid()) {
|
|
||||||
// $entityManager->flush();
|
|
||||||
//
|
|
||||||
// return $this->redirectToRoute('brand_index', [], Response::HTTP_SEE_OTHER);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return $this->renderForm('brand/edit.html.twig', [
|
|
||||||
// 'brand' => $brand,
|
|
||||||
// 'form' => $form,
|
|
||||||
// ]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/{id}', name: 'brand_delete', methods: ['POST'])]
|
#[Route('/{id}', name: 'brand_delete', methods: ['POST'])]
|
||||||
public function delete(Request $request, Brand $brand): Response
|
public function delete(Request $request, Brand $brand): Response
|
||||||
{
|
{
|
||||||
return $this->deleteCSRF($request, $brand);
|
return $this->deleteCSRF($request, $brand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +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;
|
use App\Traits\{DeleteFormTrait, FormControllerTrait};
|
||||||
use App\Traits\FormControllerTrait;
|
use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException};
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Doctrine\ORM\ORMInvalidArgumentException;
|
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
@ -21,12 +19,12 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
class CameraController extends AbstractController
|
class CameraController extends AbstractController
|
||||||
{
|
{
|
||||||
use FormControllerTrait;
|
use FormControllerTrait;
|
||||||
use DeleteFormTrait;
|
use DeleteFormTrait;
|
||||||
|
|
||||||
protected const ENTITY = Camera::class;
|
protected const ENTITY = Camera::class;
|
||||||
protected const TEMPLATE_PATH = 'camera/';
|
protected const TEMPLATE_PATH = 'camera/';
|
||||||
protected const ROUTE_PREFIX = 'camera_';
|
protected const ROUTE_PREFIX = 'camera_';
|
||||||
protected const FORM = CameraType::class;
|
protected const FORM = CameraType::class;
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
@ -69,7 +67,7 @@ class CameraController extends AbstractController
|
|||||||
#[Route(path: '/new', name: 'camera_new', methods: ['GET', 'POST'])]
|
#[Route(path: '/new', name: 'camera_new', methods: ['GET', 'POST'])]
|
||||||
public function newAction(Request $request): RedirectResponse|Response
|
public function newAction(Request $request): RedirectResponse|Response
|
||||||
{
|
{
|
||||||
return $this->itemCreate($request,'camera');
|
return $this->itemCreate($request, 'camera');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +76,7 @@ class CameraController extends AbstractController
|
|||||||
#[Route(path: '/{id}', name: 'camera_show', methods: ['GET'])]
|
#[Route(path: '/{id}', name: 'camera_show', methods: ['GET'])]
|
||||||
public function showAction(Camera $camera): Response
|
public function showAction(Camera $camera): Response
|
||||||
{
|
{
|
||||||
return $this->itemView($camera,'camera');
|
return $this->itemView($camera, 'camera');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,7 +87,7 @@ class CameraController extends AbstractController
|
|||||||
#[Route(path: '/{id}/edit', name: 'camera_edit', methods: ['GET', 'POST'])]
|
#[Route(path: '/{id}/edit', name: 'camera_edit', methods: ['GET', 'POST'])]
|
||||||
public function editAction(Request $request, Camera $camera): RedirectResponse|Response
|
public function editAction(Request $request, Camera $camera): RedirectResponse|Response
|
||||||
{
|
{
|
||||||
return $this->itemUpdate($request, $camera,'camera');
|
return $this->itemUpdate($request, $camera, 'camera');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,7 +95,7 @@ class CameraController extends AbstractController
|
|||||||
*
|
*
|
||||||
* @throws LogicException
|
* @throws LogicException
|
||||||
*/
|
*/
|
||||||
#[Route(path: '/{id}', name: 'camera_delete', methods: ['POST','DELETE'])]
|
#[Route(path: '/{id}', name: 'camera_delete', methods: ['POST', 'DELETE'])]
|
||||||
public function deleteAction(Request $request, Camera $camera): RedirectResponse
|
public function deleteAction(Request $request, Camera $camera): RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->itemDelete($request, $camera);
|
return $this->itemDelete($request, $camera);
|
||||||
|
@ -4,8 +4,7 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use App\Entity\CameraType;
|
use App\Entity\CameraType;
|
||||||
use App\Form\CameraTypeType;
|
use App\Form\CameraTypeType;
|
||||||
use App\Traits\DeleteFormTrait;
|
use App\Traits\{DeleteFormTrait, FormControllerTrait};
|
||||||
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\{RedirectResponse, Request, Response};
|
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
|
||||||
@ -15,12 +14,12 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
class CameraTypeController extends AbstractController
|
class CameraTypeController extends AbstractController
|
||||||
{
|
{
|
||||||
use FormControllerTrait;
|
use FormControllerTrait;
|
||||||
use DeleteFormTrait;
|
use DeleteFormTrait;
|
||||||
|
|
||||||
protected const ENTITY = CameraType::class;
|
protected const ENTITY = CameraType::class;
|
||||||
protected const TEMPLATE_PATH = 'cameratype/';
|
protected const TEMPLATE_PATH = 'cameratype/';
|
||||||
protected const ROUTE_PREFIX = 'camera-type_';
|
protected const ROUTE_PREFIX = 'camera-type_';
|
||||||
protected const FORM = CameraTypeType::class;
|
protected const FORM = CameraTypeType::class;
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
@ -43,7 +42,7 @@ class CameraTypeController extends AbstractController
|
|||||||
#[Route(path: '/new', name: 'camera-type_new', methods: ['GET', 'POST'])]
|
#[Route(path: '/new', name: 'camera-type_new', methods: ['GET', 'POST'])]
|
||||||
public function newAction(Request $request): Response
|
public function newAction(Request $request): Response
|
||||||
{
|
{
|
||||||
return $this->itemCreate($request, 'cameraType');
|
return $this->itemCreate($request, 'cameraType');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +51,7 @@ class CameraTypeController extends AbstractController
|
|||||||
#[Route(path: '/{id}', name: 'camera-type_show', methods: ['GET'])]
|
#[Route(path: '/{id}', name: 'camera-type_show', methods: ['GET'])]
|
||||||
public function showAction(CameraType $cameraType): Response
|
public function showAction(CameraType $cameraType): Response
|
||||||
{
|
{
|
||||||
return $this->itemView($cameraType, 'cameraType');
|
return $this->itemView($cameraType, 'cameraType');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,8 +4,7 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use App\Entity\Film;
|
use App\Entity\Film;
|
||||||
use App\Form\FilmType;
|
use App\Form\FilmType;
|
||||||
use App\Traits\DeleteFormTrait;
|
use App\Traits\{DeleteFormTrait, FormControllerTrait};
|
||||||
use App\Traits\FormControllerTrait;
|
|
||||||
use Doctrine\Common\Collections\Criteria;
|
use Doctrine\Common\Collections\Criteria;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
@ -20,12 +19,12 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
class FilmController extends AbstractController
|
class FilmController extends AbstractController
|
||||||
{
|
{
|
||||||
use FormControllerTrait;
|
use FormControllerTrait;
|
||||||
use DeleteFormTrait;
|
use DeleteFormTrait;
|
||||||
|
|
||||||
protected const ENTITY = Film::class;
|
protected const ENTITY = Film::class;
|
||||||
protected const TEMPLATE_PATH = 'film/';
|
protected const TEMPLATE_PATH = 'film/';
|
||||||
protected const ROUTE_PREFIX = 'film_';
|
protected const ROUTE_PREFIX = 'film_';
|
||||||
protected const FORM = FilmType::class;
|
protected const FORM = FilmType::class;
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
@ -95,7 +94,7 @@ class FilmController extends AbstractController
|
|||||||
*
|
*
|
||||||
* @throws LogicException
|
* @throws LogicException
|
||||||
*/
|
*/
|
||||||
#[Route(path: '/{id}', name: 'film_delete', methods: ['POST','DELETE'])]
|
#[Route(path: '/{id}', name: 'film_delete', methods: ['POST', 'DELETE'])]
|
||||||
public function deleteAction(Request $request, Film $film): RedirectResponse
|
public function deleteAction(Request $request, Film $film): RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->itemDelete($request, $film);
|
return $this->itemDelete($request, $film);
|
||||||
|
@ -4,11 +4,9 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use App\Entity\Flash;
|
use App\Entity\Flash;
|
||||||
use App\Form\FlashType;
|
use App\Form\FlashType;
|
||||||
use App\Traits\DeleteFormTrait;
|
use App\Traits\{DeleteFormTrait, FormControllerTrait};
|
||||||
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\Form\FormInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
|
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
@ -19,12 +17,12 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
class FlashController extends AbstractController
|
class FlashController extends AbstractController
|
||||||
{
|
{
|
||||||
use FormControllerTrait;
|
use FormControllerTrait;
|
||||||
use DeleteFormTrait;
|
use DeleteFormTrait;
|
||||||
|
|
||||||
protected const ENTITY = Flash::class;
|
protected const ENTITY = Flash::class;
|
||||||
protected const TEMPLATE_PATH = 'flash/';
|
protected const TEMPLATE_PATH = 'flash/';
|
||||||
protected const ROUTE_PREFIX = 'flash_';
|
protected const ROUTE_PREFIX = 'flash_';
|
||||||
protected const FORM = FlashType::class;
|
protected const FORM = FlashType::class;
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
@ -45,7 +43,7 @@ class FlashController extends AbstractController
|
|||||||
#[Route(path: '/new', name: 'flash_new', methods: ['GET', 'POST'])]
|
#[Route(path: '/new', name: 'flash_new', methods: ['GET', 'POST'])]
|
||||||
public function newAction(Request $request): RedirectResponse|Response
|
public function newAction(Request $request): RedirectResponse|Response
|
||||||
{
|
{
|
||||||
return $this->itemCreate($request,'flash');
|
return $this->itemCreate($request, 'flash');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +52,7 @@ class FlashController extends AbstractController
|
|||||||
#[Route(path: '/{id}', name: 'flash_show', methods: ['GET'])]
|
#[Route(path: '/{id}', name: 'flash_show', methods: ['GET'])]
|
||||||
public function showAction(Flash $flash): Response
|
public function showAction(Flash $flash): Response
|
||||||
{
|
{
|
||||||
return $this->itemView($flash,'flash');
|
return $this->itemView($flash, 'flash');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
@ -7,57 +7,56 @@ use App\Form\GPUCoreType;
|
|||||||
use App\Traits\FormControllerTrait;
|
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, Response};
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
#[Route('/gpu-core')]
|
#[Route('/gpu-core')]
|
||||||
class GpuCoreController extends AbstractController
|
class GpuCoreController extends AbstractController
|
||||||
{
|
{
|
||||||
use FormControllerTrait;
|
use FormControllerTrait;
|
||||||
|
|
||||||
protected const ENTITY = GpuCore::class;
|
protected const ENTITY = GpuCore::class;
|
||||||
protected const TEMPLATE_PATH = 'gpu_core/';
|
protected const TEMPLATE_PATH = 'gpu_core/';
|
||||||
protected const ROUTE_PREFIX = 'gpu-core_';
|
protected const ROUTE_PREFIX = 'gpu-core_';
|
||||||
protected const FORM = GPUCoreType::class;
|
protected const FORM = GPUCoreType::class;
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/', name: 'gpu-core_index', methods: ['GET'])]
|
#[Route('/', name: 'gpu-core_index', methods: ['GET'])]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
return $this->indexView('gpu_cores', [
|
return $this->indexView('gpu_cores', [
|
||||||
'brand' => 'asc',
|
'brand' => 'asc',
|
||||||
'architecture' => 'asc',
|
'architecture' => 'asc',
|
||||||
'name' => 'asc',
|
'name' => 'asc',
|
||||||
'variant' => 'asc',
|
'variant' => 'asc',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/new', name: 'gpu-core_new', methods: ['GET', 'POST'])]
|
#[Route('/new', name: 'gpu-core_new', methods: ['GET', 'POST'])]
|
||||||
public function new(Request $request): Response
|
public function new(Request $request): Response
|
||||||
{
|
{
|
||||||
return $this->itemCreate($request, 'gpu_core');
|
return $this->itemCreate($request, 'gpu_core');
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/{id}', name: 'gpu-core_show', methods: ['GET'])]
|
#[Route('/{id}', name: 'gpu-core_show', methods: ['GET'])]
|
||||||
public function show(GpuCore $gPUCore): Response
|
public function show(GpuCore $gPUCore): Response
|
||||||
{
|
{
|
||||||
return $this->itemView($gPUCore, 'gpu_core');
|
return $this->itemView($gPUCore, 'gpu_core');
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/{id}/edit', name: 'gpu-core_edit', methods: ['GET', 'POST'])]
|
#[Route('/{id}/edit', name: 'gpu-core_edit', methods: ['GET', 'POST'])]
|
||||||
public function edit(Request $request, GpuCore $gPUCore): Response
|
public function edit(Request $request, GpuCore $gPUCore): Response
|
||||||
{
|
{
|
||||||
return $this->itemUpdate($request, $gPUCore, 'gpu_core');
|
return $this->itemUpdate($request, $gPUCore, 'gpu_core');
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/{id}', name: 'gpu-core_delete', methods: ['POST'])]
|
#[Route('/{id}', name: 'gpu-core_delete', methods: ['POST'])]
|
||||||
public function delete(Request $request, GpuCore $gPUCore, EntityManagerInterface $entityManager): Response
|
public function delete(Request $request, GpuCore $gPUCore, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
if ($this->isCsrfTokenValid('delete'.$gPUCore->getId(), $request->request->get('_token'))) {
|
if ($this->isCsrfTokenValid('delete' . $gPUCore->getId(), $request->request->get('_token'))) {
|
||||||
$entityManager->remove($gPUCore);
|
$entityManager->remove($gPUCore);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,7 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use App\Entity\Lenses;
|
use App\Entity\Lenses;
|
||||||
use App\Form\LensesType;
|
use App\Form\LensesType;
|
||||||
use App\Traits\DeleteFormTrait;
|
use App\Traits\{DeleteFormTrait, FormControllerTrait};
|
||||||
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\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
@ -19,12 +18,12 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
class LensesController extends AbstractController
|
class LensesController extends AbstractController
|
||||||
{
|
{
|
||||||
use FormControllerTrait;
|
use FormControllerTrait;
|
||||||
use DeleteFormTrait;
|
use DeleteFormTrait;
|
||||||
|
|
||||||
protected const ENTITY = Lenses::class;
|
protected const ENTITY = Lenses::class;
|
||||||
protected const TEMPLATE_PATH = 'lenses/';
|
protected const TEMPLATE_PATH = 'lenses/';
|
||||||
protected const ROUTE_PREFIX = 'lens_';
|
protected const ROUTE_PREFIX = 'lens_';
|
||||||
protected const FORM = LensesType::class;
|
protected const FORM = LensesType::class;
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
@ -67,7 +66,7 @@ class LensesController extends AbstractController
|
|||||||
#[Route(path: '/new', name: 'lens_new', methods: ['GET', 'POST'])]
|
#[Route(path: '/new', name: 'lens_new', methods: ['GET', 'POST'])]
|
||||||
public function newAction(Request $request): RedirectResponse|Response
|
public function newAction(Request $request): RedirectResponse|Response
|
||||||
{
|
{
|
||||||
return $this->itemCreate($request,'lense');
|
return $this->itemCreate($request, 'lense');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,7 +103,7 @@ class LensesController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* Deletes a lens entity.
|
* Deletes a lens entity.
|
||||||
*/
|
*/
|
||||||
#[Route(path: '/{id}', name: 'lens_delete', methods: ['POST','DELETE'])]
|
#[Route(path: '/{id}', name: 'lens_delete', methods: ['POST', 'DELETE'])]
|
||||||
public function deleteAction(Request $request, Lenses $lens): RedirectResponse
|
public function deleteAction(Request $request, Lenses $lens): RedirectResponse
|
||||||
{
|
{
|
||||||
return $this->itemDelete($request, $lens);
|
return $this->itemDelete($request, $lens);
|
||||||
|
@ -5,8 +5,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\Traits\FormControllerTrait;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\{EntityManagerInterface, ORMInvalidArgumentException};
|
||||||
use Doctrine\ORM\ORMInvalidArgumentException;
|
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
@ -22,10 +21,10 @@ class PreviouslyOwnedCameraController extends AbstractController
|
|||||||
{
|
{
|
||||||
use FormControllerTrait;
|
use FormControllerTrait;
|
||||||
|
|
||||||
protected const ENTITY = PreviouslyOwnedCamera::class;
|
protected const ENTITY = PreviouslyOwnedCamera::class;
|
||||||
protected const TEMPLATE_PATH = 'previouslyownedcamera/';
|
protected const TEMPLATE_PATH = 'previouslyownedcamera/';
|
||||||
protected const ROUTE_PREFIX = 'previously-owned-camera_';
|
protected const ROUTE_PREFIX = 'previously-owned-camera_';
|
||||||
protected const FORM = PreviouslyOwnedCameraType::class;
|
protected const FORM = PreviouslyOwnedCameraType::class;
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
@ -39,7 +38,7 @@ class PreviouslyOwnedCameraController extends AbstractController
|
|||||||
#[Route(path: '/', name: 'previously-owned-camera_index', methods: ['GET'])]
|
#[Route(path: '/', name: 'previously-owned-camera_index', methods: ['GET'])]
|
||||||
public function indexAction(): Response
|
public function indexAction(): Response
|
||||||
{
|
{
|
||||||
return $this->itemListView( 'previouslyOwnedCameras', [
|
return $this->itemListView('previouslyOwnedCameras', [
|
||||||
'brand' => 'ASC',
|
'brand' => 'ASC',
|
||||||
'mount' => 'ASC',
|
'mount' => 'ASC',
|
||||||
'model' => 'ASC',
|
'model' => 'ASC',
|
||||||
|
@ -18,10 +18,10 @@ class PreviouslyOwnedFlashController extends AbstractController
|
|||||||
{
|
{
|
||||||
use FormControllerTrait;
|
use FormControllerTrait;
|
||||||
|
|
||||||
protected const ENTITY = PreviouslyOwnedFlash::class;
|
protected const ENTITY = PreviouslyOwnedFlash::class;
|
||||||
protected const ROUTE_PREFIX = 'previously-owned-flash_';
|
protected const ROUTE_PREFIX = 'previously-owned-flash_';
|
||||||
protected const TEMPLATE_PATH = 'previouslyownedflash/';
|
protected const TEMPLATE_PATH = 'previouslyownedflash/';
|
||||||
protected const FORM = PreviouslyOwnedFlashType::class;
|
protected const FORM = PreviouslyOwnedFlashType::class;
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
@ -33,7 +33,7 @@ class PreviouslyOwnedFlashController extends AbstractController
|
|||||||
#[Route(path: '/', name: 'previously-owned-flash_index', methods: ['GET'])]
|
#[Route(path: '/', name: 'previously-owned-flash_index', methods: ['GET'])]
|
||||||
public function indexAction(): Response
|
public function indexAction(): Response
|
||||||
{
|
{
|
||||||
return $this->itemListView( 'previouslyOwnedFlashes');
|
return $this->itemListView('previouslyOwnedFlashes');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,10 +15,10 @@ class PreviouslyOwnedLensesController extends AbstractController
|
|||||||
{
|
{
|
||||||
use FormControllerTrait;
|
use FormControllerTrait;
|
||||||
|
|
||||||
protected const ENTITY = PreviouslyOwnedLenses::class;
|
protected const ENTITY = PreviouslyOwnedLenses::class;
|
||||||
protected const TEMPLATE_PATH = 'previouslyownedlenses/';
|
protected const TEMPLATE_PATH = 'previouslyownedlenses/';
|
||||||
protected const ROUTE_PREFIX = 'previously-owned-lens_';
|
protected const ROUTE_PREFIX = 'previously-owned-lens_';
|
||||||
protected const FORM = PreviouslyOwnedLensesType::class;
|
protected const FORM = PreviouslyOwnedLensesType::class;
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
|
@ -8,21 +8,21 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
#[ORM\Entity]
|
#[ORM\Entity]
|
||||||
class Brand
|
class Brand
|
||||||
{
|
{
|
||||||
use GetSetTrait;
|
use GetSetTrait;
|
||||||
|
|
||||||
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
|
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
|
||||||
#[ORM\SequenceGenerator(sequenceName: 'brand_id_seq', allocationSize: 1, initialValue: 1)]
|
#[ORM\SequenceGenerator(sequenceName: 'brand_id_seq', allocationSize: 1, initialValue: 1)]
|
||||||
private int $id;
|
private int $id;
|
||||||
|
|
||||||
#[ORM\Column(name: 'name', unique: true, nullable: FALSE)]
|
#[ORM\Column(name: 'name', unique: TRUE, nullable: FALSE)]
|
||||||
private string $name;
|
private string $name;
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Doctrine\DBAL\Types\Types;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Stringable;
|
use Stringable;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Doctrine\DBAL\Types\Types;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,32 +2,31 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
trait GetSetTrait {
|
use InvalidArgumentException;
|
||||||
public function __call(string $name, array $arguments): mixed
|
|
||||||
{
|
|
||||||
if (method_exists($this, $name))
|
|
||||||
{
|
|
||||||
return $this->$name(...$arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apparently Doctrine first tries the method with the same
|
trait GetSetTrait
|
||||||
// name as the property, instead of with the get prefix
|
{
|
||||||
if (property_exists($this, $name) && empty($arguments))
|
public function __call(string $name, array $arguments): mixed
|
||||||
{
|
{
|
||||||
return $this->$name;
|
if (method_exists($this, $name)) {
|
||||||
}
|
return $this->{$name}(...$arguments);
|
||||||
|
}
|
||||||
|
|
||||||
if (str_starts_with('set', $name))
|
// Apparently Doctrine first tries the method with the same
|
||||||
{
|
// name as the property, instead of with the get prefix
|
||||||
$var = lcfirst(str_replace('set', '', $name));
|
if (property_exists($this, $name) && empty($arguments)) {
|
||||||
if (property_exists($this, $var))
|
return $this->{$name};
|
||||||
{
|
}
|
||||||
$this->$name = $arguments[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
if (str_starts_with('set', $name)) {
|
||||||
}
|
$var = lcfirst(str_replace('set', '', $name));
|
||||||
|
if (property_exists($this, $var)) {
|
||||||
|
$this->{$name} = $arguments[0];
|
||||||
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException("Undefined method: {$name}");
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw new InvalidArgumentException("Undefined method: {$name}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,43 +2,42 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use Doctrine\DBAL\Types\Types;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Table(name: 'gpu', schema: 'collection')]
|
#[ORM\Table(name: 'gpu', schema: 'collection')]
|
||||||
#[ORM\Entity]
|
#[ORM\Entity]
|
||||||
class Gpu
|
class Gpu
|
||||||
{
|
{
|
||||||
use GetSetTrait;
|
use GetSetTrait;
|
||||||
|
|
||||||
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
|
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
|
||||||
private int $id;
|
private int $id;
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: 'Brand')]
|
#[ORM\ManyToOne(targetEntity: 'Brand')]
|
||||||
#[ORM\JoinColumn(name: 'board_brand_id', referencedColumnName: 'id', nullable: TRUE)]
|
#[ORM\JoinColumn(name: 'board_brand_id', referencedColumnName: 'id', nullable: TRUE)]
|
||||||
private readonly Brand $boardBrand;
|
private readonly Brand $boardBrand;
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: 'Brand')]
|
#[ORM\ManyToOne(targetEntity: 'Brand')]
|
||||||
#[ORM\JoinColumn(name: 'gpu_brand_id', referencedColumnName: 'id', nullable: FALSE)]
|
#[ORM\JoinColumn(name: 'gpu_brand_id', referencedColumnName: 'id', nullable: FALSE)]
|
||||||
private readonly Brand $gpuBrand;
|
private readonly Brand $gpuBrand;
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: 'GpuCore')]
|
#[ORM\ManyToOne(targetEntity: 'GpuCore')]
|
||||||
#[ORM\JoinColumn(name: 'gpu_core_id', referencedColumnName: 'id', nullable: TRUE)]
|
#[ORM\JoinColumn(name: 'gpu_core_id', referencedColumnName: 'id', nullable: TRUE)]
|
||||||
private readonly GpuCore $gpuCore;
|
private readonly GpuCore $gpuCore;
|
||||||
|
|
||||||
#[ORM\Column(name: 'reference_model_name', nullable: FALSE)]
|
#[ORM\Column(name: 'reference_model_name', nullable: FALSE)]
|
||||||
private readonly string $modelName;
|
private readonly string $modelName;
|
||||||
|
|
||||||
#[ORM\Column(name: 'alternate_model_name', nullable: TRUE)]
|
#[ORM\Column(name: 'alternate_model_name', nullable: TRUE)]
|
||||||
private readonly string $alternateModelName;
|
private readonly string $alternateModelName;
|
||||||
|
|
||||||
#[ORM\Column(name: 'count', nullable: FALSE)]
|
#[ORM\Column(name: 'count', nullable: FALSE)]
|
||||||
private readonly int $count;
|
private readonly int $count;
|
||||||
|
|
||||||
#[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)]
|
#[ORM\Column(name: 'notes', type: 'text', nullable: TRUE)]
|
||||||
private readonly string $notes;
|
private readonly string $notes;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
|
@ -2,134 +2,132 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Repository\GPURepository;
|
|
||||||
use Doctrine\DBAL\Types\Types;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Table(name: 'gpu_core', schema: 'collection')]
|
#[ORM\Table(name: 'gpu_core', schema: 'collection')]
|
||||||
#[ORM\Entity]
|
#[ORM\Entity]
|
||||||
class GpuCore
|
class GpuCore
|
||||||
{
|
{
|
||||||
use GetSetTrait;
|
use GetSetTrait;
|
||||||
|
|
||||||
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
|
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
|
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
|
||||||
private int $id;
|
private int $id;
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: 'Brand')]
|
#[ORM\ManyToOne(targetEntity: 'Brand')]
|
||||||
#[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id')]
|
#[ORM\JoinColumn(name: 'brand_id', referencedColumnName: 'id')]
|
||||||
private Brand $brand;
|
private Brand $brand;
|
||||||
|
|
||||||
#[ORM\Column(name: 'name')]
|
#[ORM\Column(name: 'name')]
|
||||||
private readonly string $name;
|
private readonly string $name;
|
||||||
|
|
||||||
#[ORM\Column(name: 'variant', nullable: TRUE)]
|
#[ORM\Column(name: 'variant', nullable: TRUE)]
|
||||||
private readonly ?string $variant;
|
private readonly ?string $variant;
|
||||||
|
|
||||||
#[ORM\Column(name: 'generation_name')]
|
#[ORM\Column(name: 'generation_name')]
|
||||||
private readonly string $generationName;
|
private readonly string $generationName;
|
||||||
|
|
||||||
#[ORM\Column(name: 'architecture')]
|
#[ORM\Column(name: 'architecture')]
|
||||||
private readonly string $architecture;
|
private readonly string $architecture;
|
||||||
|
|
||||||
#[ORM\Column(name: 'architecture_link')]
|
#[ORM\Column(name: 'architecture_link')]
|
||||||
private readonly string $architectureLink;
|
private readonly string $architectureLink;
|
||||||
|
|
||||||
#[ORM\Column(name: 'process_node', nullable: TRUE)]
|
#[ORM\Column(name: 'process_node', nullable: TRUE)]
|
||||||
private readonly ?int $processNode;
|
private readonly ?int $processNode;
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return "$this->brand $this->name ($this->variant/$this->generationName)";
|
return "{$this->brand} {$this->name} ({$this->variant}/{$this->generationName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): ?string
|
public function getName(): ?string
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setName(string $name): self
|
public function setName(string $name): self
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVariant(): ?string
|
public function getVariant(): ?string
|
||||||
{
|
{
|
||||||
return $this->variant;
|
return $this->variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setVariant(string $variant): self
|
public function setVariant(string $variant): self
|
||||||
{
|
{
|
||||||
$this->variant = $variant;
|
$this->variant = $variant;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGenerationName(): ?string
|
public function getGenerationName(): ?string
|
||||||
{
|
{
|
||||||
return $this->generationName;
|
return $this->generationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setGenerationName(string $generationName): self
|
public function setGenerationName(string $generationName): self
|
||||||
{
|
{
|
||||||
$this->generationName = $generationName;
|
$this->generationName = $generationName;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArchitecture(): ?string
|
public function getArchitecture(): ?string
|
||||||
{
|
{
|
||||||
return $this->architecture;
|
return $this->architecture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setArchitecture(string $architecture): self
|
public function setArchitecture(string $architecture): self
|
||||||
{
|
{
|
||||||
$this->architecture = $architecture;
|
$this->architecture = $architecture;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArchitectureLink(): ?string
|
public function getArchitectureLink(): ?string
|
||||||
{
|
{
|
||||||
return $this->architectureLink;
|
return $this->architectureLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setArchitectureLink(string $architectureLink): self
|
public function setArchitectureLink(string $architectureLink): self
|
||||||
{
|
{
|
||||||
$this->architectureLink = $architectureLink;
|
$this->architectureLink = $architectureLink;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProcessNode(): ?int
|
public function getProcessNode(): ?int
|
||||||
{
|
{
|
||||||
return $this->processNode;
|
return $this->processNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setProcessNode(int $processNode): self
|
public function setProcessNode(int $processNode): self
|
||||||
{
|
{
|
||||||
$this->processNode = $processNode;
|
$this->processNode = $processNode;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBrand(): ?Brand
|
public function getBrand(): ?Brand
|
||||||
{
|
{
|
||||||
return $this->brand;
|
return $this->brand;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBrand(?Brand $brand): self
|
public function setBrand(?Brand $brand): self
|
||||||
{
|
{
|
||||||
$this->brand = $brand;
|
$this->brand = $brand;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
trait LensTrait
|
trait LensTrait
|
||||||
{
|
{
|
||||||
use PurchasePriceTrait;
|
use PurchasePriceTrait;
|
||||||
use GetSetTrait;
|
use GetSetTrait;
|
||||||
|
|
||||||
#[ORM\Column(name: 'brand', type: 'string', length: 64, nullable: TRUE)]
|
#[ORM\Column(name: 'brand', type: 'string', length: 64, nullable: TRUE)]
|
||||||
private readonly ?string $brand;
|
private readonly ?string $brand;
|
||||||
@ -63,13 +63,12 @@ trait LensTrait
|
|||||||
#[ORM\Column(name: 'aperture_blades', type: 'smallint', nullable: TRUE)]
|
#[ORM\Column(name: 'aperture_blades', type: 'smallint', nullable: TRUE)]
|
||||||
private readonly ?int $apertureBlades;
|
private readonly ?int $apertureBlades;
|
||||||
|
|
||||||
public function __get(string $name): mixed
|
public function __get(string $name): mixed
|
||||||
{
|
{
|
||||||
if (property_exists($this, $name))
|
if (property_exists($this, $name)) {
|
||||||
{
|
return $this->{$name};
|
||||||
return $this->$name;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
use App\Entity\Brand;
|
use App\Entity\Brand;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class BrandType extends AbstractType
|
class BrandType extends AbstractType
|
||||||
@ -12,8 +11,7 @@ class BrandType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('name')
|
->add('name');
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
use App\Entity\GpuCore;
|
use App\Entity\GpuCore;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\{AbstractType, FormBuilderInterface};
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
class GPUCoreType extends AbstractType
|
class GPUCoreType extends AbstractType
|
||||||
@ -12,14 +11,13 @@ class GPUCoreType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('brand')
|
->add('brand')
|
||||||
->add('name')
|
->add('name')
|
||||||
->add('variant')
|
->add('variant')
|
||||||
->add('architecture')
|
->add('architecture')
|
||||||
->add('architectureLink')
|
->add('architectureLink')
|
||||||
->add('generationName')
|
->add('generationName')
|
||||||
->add('processNode')
|
->add('processNode');
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
@ -7,42 +7,39 @@ use Doctrine\ORM\{EntityRepository};
|
|||||||
use ReflectionObject;
|
use ReflectionObject;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
|
|
||||||
abstract class AcquireRepository extends EntityRepository
|
abstract class AcquireRepository extends EntityRepository
|
||||||
{
|
{
|
||||||
abstract public function reacquire(mixed $currentRecord): void;
|
abstract public function reacquire(mixed $currentRecord): void;
|
||||||
abstract public function deacquire(mixed $currentRecord): void;
|
|
||||||
|
|
||||||
/**
|
abstract public function deacquire(mixed $currentRecord): void;
|
||||||
* Move a record from the table represented by $currentRecord
|
|
||||||
* into the table represented by $newRecord
|
|
||||||
*
|
|
||||||
* @param mixed $currentRecord
|
|
||||||
* @param mixed $newRecord
|
|
||||||
*/
|
|
||||||
protected function moveRecord(mixed $currentRecord, mixed $newRecord): void
|
|
||||||
{
|
|
||||||
$em = $this->getEntityManager();
|
|
||||||
|
|
||||||
$old = new ReflectionObject($currentRecord);
|
/**
|
||||||
$new = new ReflectionObject($newRecord);
|
* Move a record from the table represented by $currentRecord
|
||||||
|
* into the table represented by $newRecord
|
||||||
|
*/
|
||||||
|
protected function moveRecord(mixed $currentRecord, mixed $newRecord): void
|
||||||
|
{
|
||||||
|
$em = $this->getEntityManager();
|
||||||
|
|
||||||
foreach ($old->getProperties() as $property) {
|
$old = new ReflectionObject($currentRecord);
|
||||||
$propertyName = $property->getName();
|
$new = new ReflectionObject($newRecord);
|
||||||
if ($new->hasProperty($propertyName)) {
|
|
||||||
$newProperty = $new->getProperty($propertyName);
|
|
||||||
$newProperty->setAccessible(TRUE);
|
|
||||||
$property->setAccessible(TRUE);
|
|
||||||
$newProperty->setValue($newRecord, $property->getValue($currentRecord));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
foreach ($old->getProperties() as $property) {
|
||||||
$em->persist($newRecord);
|
$propertyName = $property->getName();
|
||||||
$em->remove($currentRecord);
|
if ($new->hasProperty($propertyName)) {
|
||||||
$em->flush();
|
$newProperty = $new->getProperty($propertyName);
|
||||||
} catch (Throwable) {
|
$newProperty->setAccessible(TRUE);
|
||||||
dump($newRecord);
|
$property->setAccessible(TRUE);
|
||||||
}
|
$newProperty->setValue($newRecord, $property->getValue($currentRecord));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$em->persist($newRecord);
|
||||||
|
$em->remove($currentRecord);
|
||||||
|
$em->flush();
|
||||||
|
} catch (Throwable) {
|
||||||
|
dump($newRecord);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@ use Symfony\Component\Form\FormInterface;
|
|||||||
|
|
||||||
trait DeleteFormTrait
|
trait DeleteFormTrait
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a form to delete an entity.
|
* Creates a form to delete an entity.
|
||||||
*/
|
*/
|
||||||
private function createDeleteForm(mixed $item): FormInterface
|
private function createDeleteForm(mixed $item): FormInterface
|
||||||
{
|
{
|
||||||
return $this->buildForm($item, self::ROUTE_PREFIX . 'delete', 'DELETE');
|
return $this->buildForm($item, self::ROUTE_PREFIX . 'delete', 'DELETE');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
|
|||||||
|
|
||||||
trait FormControllerTrait
|
trait FormControllerTrait
|
||||||
{
|
{
|
||||||
private readonly EntityManagerInterface $entityManager;
|
private readonly EntityManagerInterface $entityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a form generator
|
* Create a form generator
|
||||||
@ -25,9 +25,9 @@ trait FormControllerTrait
|
|||||||
* Show create form / create an item
|
* Show create form / create an item
|
||||||
*/
|
*/
|
||||||
protected function itemCreate(Request $request, string $templateKey): RedirectResponse|Response
|
protected function itemCreate(Request $request, string $templateKey): RedirectResponse|Response
|
||||||
{
|
{
|
||||||
$template = self::TEMPLATE_PATH . 'new.html.twig';
|
$template = self::TEMPLATE_PATH . 'new.html.twig';
|
||||||
$redirectRoute = self::ROUTE_PREFIX . 'show';
|
$redirectRoute = self::ROUTE_PREFIX . 'show';
|
||||||
|
|
||||||
$Entity = self::ENTITY;
|
$Entity = self::ENTITY;
|
||||||
$item = new $Entity();
|
$item = new $Entity();
|
||||||
@ -49,17 +49,17 @@ trait FormControllerTrait
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function indexView(string $templateKey, array $sort = []): Response
|
protected function indexView(string $templateKey, array $sort = []): Response
|
||||||
{
|
{
|
||||||
return $this->itemListView($templateKey, $sort);
|
return $this->itemListView($templateKey, $sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List view for the data type
|
* List view for the data type
|
||||||
*/
|
*/
|
||||||
protected function itemListView(string $templateKey, array $sort = []): Response
|
protected function itemListView(string $templateKey, array $sort = []): Response
|
||||||
{
|
{
|
||||||
$template = self::TEMPLATE_PATH . 'index.html.twig';
|
$template = self::TEMPLATE_PATH . 'index.html.twig';
|
||||||
|
|
||||||
$items = $this->entityManager->getRepository(self::ENTITY)->findBy([], $sort);
|
$items = $this->entityManager->getRepository(self::ENTITY)->findBy([], $sort);
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ trait FormControllerTrait
|
|||||||
*/
|
*/
|
||||||
protected function itemView(mixed $item, string $templateKey): Response
|
protected function itemView(mixed $item, string $templateKey): Response
|
||||||
{
|
{
|
||||||
$template = self::TEMPLATE_PATH . 'show.html.twig';
|
$template = self::TEMPLATE_PATH . 'show.html.twig';
|
||||||
|
|
||||||
$templateData = [
|
$templateData = [
|
||||||
$templateKey => $item,
|
$templateKey => $item,
|
||||||
@ -91,9 +91,9 @@ trait FormControllerTrait
|
|||||||
* Show edit form / update an item
|
* Show edit form / update an item
|
||||||
*/
|
*/
|
||||||
protected function itemUpdate(Request $request, mixed $item, string $templateKey): RedirectResponse|Response
|
protected function itemUpdate(Request $request, mixed $item, string $templateKey): RedirectResponse|Response
|
||||||
{
|
{
|
||||||
$template = self::TEMPLATE_PATH . 'edit.html.twig';
|
$template = self::TEMPLATE_PATH . 'edit.html.twig';
|
||||||
$redirectRoute = self::ROUTE_PREFIX . 'show';
|
$redirectRoute = self::ROUTE_PREFIX . 'show';
|
||||||
|
|
||||||
$editForm = $this->createForm(self::FORM, $item);
|
$editForm = $this->createForm(self::FORM, $item);
|
||||||
$editForm->handleRequest($request);
|
$editForm->handleRequest($request);
|
||||||
@ -158,31 +158,31 @@ trait FormControllerTrait
|
|||||||
return $this->redirectToRoute($redirectRoute);
|
return $this->redirectToRoute($redirectRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actually delete an item
|
* Actually delete an item
|
||||||
*/
|
*/
|
||||||
protected function itemDelete(Request $request, mixed $item): RedirectResponse
|
protected function itemDelete(Request $request, mixed $item): RedirectResponse
|
||||||
{
|
{
|
||||||
$redirectRoute = self::ROUTE_PREFIX . 'index';
|
$redirectRoute = self::ROUTE_PREFIX . 'index';
|
||||||
|
|
||||||
$form = $this->createDeleteForm($item);
|
$form = $this->createDeleteForm($item);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
// if ($this->isCsrfTokenValid((string)$item->getId(), $request->request->get('_token'))) {
|
// if ($this->isCsrfTokenValid((string)$item->getId(), $request->request->get('_token'))) {
|
||||||
$this->entityManager->remove($item);
|
$this->entityManager->remove($item);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return $this->redirectToRoute($redirectRoute, [], Response::HTTP_SEE_OTHER);
|
return $this->redirectToRoute($redirectRoute, [], Response::HTTP_SEE_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function deleteCSRF(Request $request, mixed $item): RedirectResponse
|
protected function deleteCSRF(Request $request, mixed $item): RedirectResponse
|
||||||
{
|
{
|
||||||
if ($this->isCsrfTokenValid('delete'.$item->getId(), $request->request->get('_token'))) {
|
if ($this->isCsrfTokenValid('delete' . $item->getId(), $request->request->get('_token'))) {
|
||||||
$this->entityManager->remove($item);
|
$this->entityManager->remove($item);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->redirectToRoute(self::ROUTE_PREFIX . 'index', [], Response::HTTP_SEE_OTHER);
|
return $this->redirectToRoute(self::ROUTE_PREFIX . 'index', [], Response::HTTP_SEE_OTHER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,17 @@
|
|||||||
namespace App\Types;
|
namespace App\Types;
|
||||||
|
|
||||||
enum BusInterface: string {
|
enum BusInterface: string {
|
||||||
case PCI = 'PCI';
|
case PCI = 'PCI';
|
||||||
case ISA = 'ISA';
|
|
||||||
case VLB = 'VLB (Vesa Local Bus)';
|
case ISA = 'ISA';
|
||||||
case AGP = 'AGP';
|
|
||||||
case AGPX2 = 'AGP 2x';
|
case VLB = 'VLB (Vesa Local Bus)';
|
||||||
case AGPX4 = 'AGP 4x';
|
|
||||||
case AGPX8 = 'AGP 8x';
|
case AGP = 'AGP';
|
||||||
|
|
||||||
|
case AGPX2 = 'AGP 2x';
|
||||||
|
|
||||||
|
case AGPX4 = 'AGP 4x';
|
||||||
|
|
||||||
|
case AGPX8 = 'AGP 8x';
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class Money implements Stringable
|
|||||||
|
|
||||||
public function getValue(): float
|
public function getValue(): float
|
||||||
{
|
{
|
||||||
return (float) str_replace(['$', ','], '', (string)$this->value);
|
return (float) str_replace(['$', ','], '', (string) $this->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
|
Loading…
Reference in New Issue
Block a user