Fix a bunch of deprecation issues
This commit is contained in:
parent
1b2473aa83
commit
21f750e97a
@ -11,6 +11,7 @@
|
||||
"symfony/form": "^6.0.3",
|
||||
"symfony/maker-bundle": "^1.0",
|
||||
"symfony/monolog-bundle": "^3.0",
|
||||
"symfony/security-csrf": "^6.1",
|
||||
"symfony/translation": "^6.0.3",
|
||||
"symfony/twig-bundle": "^6.0",
|
||||
"symfony/validator": "^6.0.3",
|
||||
|
2115
composer.lock
generated
2115
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@ framework:
|
||||
secret: '%env(APP_SECRET)%'
|
||||
default_locale: en
|
||||
#csrf_protection: ~
|
||||
#http_method_override: true
|
||||
http_method_override: false
|
||||
#trusted_hosts: ~
|
||||
|
||||
# uncomment this entire section to enable sessions
|
||||
|
@ -4,8 +4,8 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\Camera;
|
||||
use App\Form\CameraType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\ORMInvalidArgumentException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use LogicException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@ -21,9 +21,11 @@ class CameraController extends AbstractController
|
||||
use FormControllerTrait;
|
||||
|
||||
protected const ENTITY = Camera::class;
|
||||
protected const TEMPLATE_PATH = 'camera/';
|
||||
protected const ROUTE_PREFIX = 'camera_';
|
||||
protected const FORM = CameraType::class;
|
||||
|
||||
public function __construct(private readonly ManagerRegistry $managerRegistry)
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{
|
||||
}
|
||||
|
||||
@ -33,8 +35,7 @@ class CameraController extends AbstractController
|
||||
#[Route(path: '/', name: 'camera_index', methods: ['GET'])]
|
||||
public function indexAction(): Response
|
||||
{
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$receivedItems = $em->getRepository(self::ENTITY)->findBy([
|
||||
$receivedItems = $this->entityManager->getRepository(self::ENTITY)->findBy([
|
||||
'received' => TRUE,
|
||||
], [
|
||||
'isWorking' => 'ASC',
|
||||
@ -42,7 +43,7 @@ class CameraController extends AbstractController
|
||||
'mount' => 'ASC',
|
||||
'model' => 'ASC',
|
||||
]);
|
||||
$newItems = $em->getRepository(self::ENTITY)->findBy([
|
||||
$newItems = $this->entityManager->getRepository(self::ENTITY)->findBy([
|
||||
'received' => FALSE,
|
||||
], [
|
||||
'brand' => 'ASC',
|
||||
|
@ -4,7 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\CameraType;
|
||||
use App\Form\CameraTypeType;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
|
||||
@ -16,9 +16,11 @@ class CameraTypeController extends AbstractController
|
||||
use FormControllerTrait;
|
||||
|
||||
protected const ENTITY = CameraType::class;
|
||||
protected const TEMPLATE_PATH = 'cameratype/';
|
||||
protected const ROUTE_PREFIX = 'camera-type_';
|
||||
protected const FORM = CameraTypeType::class;
|
||||
|
||||
public function __construct(private readonly ManagerRegistry $managerRegistry)
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ namespace App\Controller;
|
||||
use App\Entity\Film;
|
||||
use App\Form\FilmType;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use LogicException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@ -21,9 +22,11 @@ class FilmController extends AbstractController
|
||||
use FormControllerTrait;
|
||||
|
||||
protected const ENTITY = Film::class;
|
||||
protected const TEMPLATE_PATH = 'film/';
|
||||
protected const ROUTE_PREFIX = 'film_';
|
||||
protected const FORM = FilmType::class;
|
||||
|
||||
public function __construct(private readonly ManagerRegistry $managerRegistry)
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{
|
||||
}
|
||||
|
||||
@ -33,7 +36,7 @@ class FilmController extends AbstractController
|
||||
#[Route(path: '/', name: 'film_index', methods: ['GET'])]
|
||||
public function indexAction(): Response
|
||||
{
|
||||
$repo = $this->managerRegistry->getManager()->getRepository(self::ENTITY);
|
||||
$repo = $this->entityManager->getRepository(self::ENTITY);
|
||||
$criteria = Criteria::create()
|
||||
->where(Criteria::expr()->gt('rollsInCamera', 0))
|
||||
->orderBy([
|
||||
@ -99,10 +102,6 @@ class FilmController extends AbstractController
|
||||
|
||||
/**
|
||||
* Creates a form to delete a film entity.
|
||||
*
|
||||
* @param Film $film The film entity
|
||||
*
|
||||
* @return FormInterface The form
|
||||
*/
|
||||
private function createDeleteForm(Film $film): FormInterface
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\Flash;
|
||||
use App\Form\FlashType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@ -19,9 +20,11 @@ class FlashController extends AbstractController
|
||||
use FormControllerTrait;
|
||||
|
||||
protected const ENTITY = Flash::class;
|
||||
protected const TEMPLATE_PATH = 'flash/';
|
||||
protected const ROUTE_PREFIX = 'flash_';
|
||||
protected const FORM = FlashType::class;
|
||||
|
||||
public function __construct(private readonly ManagerRegistry $managerRegistry)
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
|
||||
|
||||
trait FormControllerTrait
|
||||
{
|
||||
private readonly ManagerRegistry $managerRegistry;
|
||||
private readonly EntityManagerInterface $entityManager;
|
||||
|
||||
/**
|
||||
* Create a form generator
|
||||
@ -35,9 +35,8 @@ trait FormControllerTrait
|
||||
|
||||
// If creating the item
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($item);
|
||||
$em->flush();
|
||||
$this->entityManager->persist($item);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute($redirectRoute, ['id' => $item->getId()]);
|
||||
}
|
||||
@ -54,9 +53,7 @@ trait FormControllerTrait
|
||||
*/
|
||||
protected function itemListView(string $template, string $templateKey, array $sort = []): Response
|
||||
{
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$items = $em->getRepository(self::ENTITY)->findBy([], $sort);
|
||||
$items = $this->entityManager->getRepository(self::ENTITY)->findBy([], $sort);
|
||||
|
||||
return $this->render($template, [
|
||||
$templateKey => $items,
|
||||
@ -94,9 +91,8 @@ trait FormControllerTrait
|
||||
|
||||
// If updating the item
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($item);
|
||||
$em->flush();
|
||||
$this->entityManager->persist($item);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute($redirectRoute, ['id' => $item->getId()]);
|
||||
}
|
||||
@ -135,7 +131,7 @@ trait FormControllerTrait
|
||||
$form = $this->createDeacquireForm($item);
|
||||
$form->handleRequest($request);
|
||||
|
||||
$repository = $this->getDoctrine()->getRepository(self::ENTITY);
|
||||
$repository = $this->entityManager->getRepository(self::ENTITY);
|
||||
$repository->deacquire($item);
|
||||
|
||||
return $this->redirectToRoute($redirectRoute);
|
||||
@ -151,7 +147,7 @@ trait FormControllerTrait
|
||||
$form = $this->createReacquireForm($item);
|
||||
$form->handleRequest($request);
|
||||
|
||||
$repository = $this->getDoctrine()->getRepository(self::ENTITY);
|
||||
$repository = $this->entityManager->getRepository(self::ENTITY);
|
||||
$repository->reacquire($item);
|
||||
|
||||
return $this->redirectToRoute($redirectRoute);
|
||||
@ -162,16 +158,13 @@ trait FormControllerTrait
|
||||
*
|
||||
* @param mixed $item
|
||||
*/
|
||||
protected function itemDelete(Request $request, $item, string $redirectRoute): RedirectResponse
|
||||
protected function itemDelete(Request $request, mixed $item, string $redirectRoute): RedirectResponse
|
||||
{
|
||||
$form = $this->createDeleteForm($item);
|
||||
$form->handleRequest($request);
|
||||
|
||||
// if ($form->isSubmitted() && $form->isValid())
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($item);
|
||||
$em->flush();
|
||||
$this->entityManager->remove($item);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute($redirectRoute);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\Lenses;
|
||||
use App\Form\LensesType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@ -19,9 +20,11 @@ class LensesController extends AbstractController
|
||||
use FormControllerTrait;
|
||||
|
||||
protected const ENTITY = Lenses::class;
|
||||
protected const TEMPLATE_PATH = 'lenses/';
|
||||
protected const ROUTE_PREFIX = 'lens_';
|
||||
protected const FORM = LensesType::class;
|
||||
|
||||
public function __construct(private readonly ManagerRegistry $managerRegistry)
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{
|
||||
}
|
||||
|
||||
@ -31,8 +34,7 @@ class LensesController extends AbstractController
|
||||
#[Route(path: '/', name: 'lens_index', methods: ['GET'])]
|
||||
public function indexAction(): Response
|
||||
{
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$receivedItems = $em->getRepository(self::ENTITY)->findBy([
|
||||
$receivedItems = $this->entityManager->getRepository(self::ENTITY)->findBy([
|
||||
'received' => TRUE,
|
||||
], [
|
||||
'brand' => 'ASC',
|
||||
@ -41,7 +43,7 @@ class LensesController extends AbstractController
|
||||
'minFocalLength' => 'ASC',
|
||||
'maxFStop' => 'ASC',
|
||||
]);
|
||||
$newItems = $em->getRepository(self::ENTITY)->findBy([
|
||||
$newItems = $this->entityManager->getRepository(self::ENTITY)->findBy([
|
||||
'received' => FALSE,
|
||||
], [
|
||||
'brand' => 'ASC',
|
||||
|
@ -4,8 +4,8 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\PreviouslyOwnedCamera;
|
||||
use App\Form\PreviouslyOwnedCameraType;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\ORMInvalidArgumentException;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use LogicException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@ -22,9 +22,11 @@ class PreviouslyOwnedCameraController extends AbstractController
|
||||
use FormControllerTrait;
|
||||
|
||||
protected const ENTITY = PreviouslyOwnedCamera::class;
|
||||
protected const TEMPLATE_PATH = 'previouslyownedcamera/';
|
||||
protected const ROUTE_PREFIX = 'previously-owned-camera_';
|
||||
protected const FORM = PreviouslyOwnedCameraType::class;
|
||||
|
||||
public function __construct(private readonly ManagerRegistry $managerRegistry)
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{
|
||||
}
|
||||
|
||||
@ -34,13 +36,13 @@ class PreviouslyOwnedCameraController extends AbstractController
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
#[Route(path: '/', name: 'previously-owned-camera_index', methods: ['GET'])]
|
||||
public function indexAction(): Response
|
||||
public function indexAction(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
return $this->itemListView('previouslyownedcamera/index.html.twig', 'previouslyOwnedCameras', [
|
||||
'brand' => 'ASC',
|
||||
'mount' => 'ASC',
|
||||
'model' => 'ASC',
|
||||
]);
|
||||
], $entityManager);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\PreviouslyOwnedFlash;
|
||||
use App\Form\PreviouslyOwnedFlashType;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
@ -18,9 +18,11 @@ class PreviouslyOwnedFlashController extends AbstractController
|
||||
use FormControllerTrait;
|
||||
|
||||
protected const ENTITY = PreviouslyOwnedFlash::class;
|
||||
protected const ROUTE_PREFIX = 'previously-owned-flash_';
|
||||
protected const TEMPLATE_PATH = 'previouslyownedflash/';
|
||||
protected const FORM = PreviouslyOwnedFlashType::class;
|
||||
|
||||
public function __construct(private readonly ManagerRegistry $managerRegistry)
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace App\Controller;
|
||||
|
||||
use App\Entity\PreviouslyOwnedLenses;
|
||||
use App\Form\PreviouslyOwnedLensesType;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\{RedirectResponse, Request, Response};
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
@ -15,9 +15,11 @@ class PreviouslyOwnedLensesController extends AbstractController
|
||||
use FormControllerTrait;
|
||||
|
||||
protected const ENTITY = PreviouslyOwnedLenses::class;
|
||||
protected const TEMPLATE_PATH = 'previouslyownedlenses/';
|
||||
protected const ROUTE_PREFIX = 'previously-owned-lens_';
|
||||
protected const FORM = PreviouslyOwnedLensesType::class;
|
||||
|
||||
public function __construct(private readonly ManagerRegistry $managerRegistry)
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{
|
||||
}
|
||||
|
||||
|
0
src/Entity/Brand.php
Normal file
0
src/Entity/Brand.php
Normal file
0
src/Entity/GPU.php
Normal file
0
src/Entity/GPU.php
Normal file
0
src/Entity/GPUCore.php
Normal file
0
src/Entity/GPUCore.php
Normal file
0
src/Entity/GetSetTrait.php
Normal file
0
src/Entity/GetSetTrait.php
Normal file
0
src/Repository/GPURepository.php
Normal file
0
src/Repository/GPURepository.php
Normal file
0
src/Types/BusInterface.php
Normal file
0
src/Types/BusInterface.php
Normal file
@ -8,14 +8,14 @@ class Money implements Stringable
|
||||
{
|
||||
private readonly float $value;
|
||||
|
||||
public function __construct($value)
|
||||
public function __construct(mixed $value)
|
||||
{
|
||||
$this->value = (float) str_replace(['$', ','], '', $value);
|
||||
$this->value = (float) str_replace(['$', ','], '', (string) $value);
|
||||
}
|
||||
|
||||
public function getValue(): float
|
||||
{
|
||||
return (float) str_replace(['$', ','], '', $this->value);
|
||||
return (float) str_replace(['$', ','], '', (string)$this->value);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
Camera 📷 CRUD
|
||||
Collection CRUD
|
||||
{% endblock %}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user