linting and updating
This commit is contained in:
parent
1a99758a0c
commit
7e00f2f8f1
21 changed files with 174 additions and 172 deletions
34
composer.lock
generated
34
composer.lock
generated
|
@ -516,16 +516,16 @@
|
|||
},
|
||||
{
|
||||
"name": "doctrine/doctrine-bundle",
|
||||
"version": "2.11.2",
|
||||
"version": "2.11.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/DoctrineBundle.git",
|
||||
"reference": "fb22c9320383caa2829c32dc3b84c1b5e0f1ceaf"
|
||||
"reference": "492725310ae9a1b5b20d6ae09fb5ae6404616e68"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/fb22c9320383caa2829c32dc3b84c1b5e0f1ceaf",
|
||||
"reference": "fb22c9320383caa2829c32dc3b84c1b5e0f1ceaf",
|
||||
"url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/492725310ae9a1b5b20d6ae09fb5ae6404616e68",
|
||||
"reference": "492725310ae9a1b5b20d6ae09fb5ae6404616e68",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -615,7 +615,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/doctrine/DoctrineBundle/issues",
|
||||
"source": "https://github.com/doctrine/DoctrineBundle/tree/2.11.2"
|
||||
"source": "https://github.com/doctrine/DoctrineBundle/tree/2.11.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -631,7 +631,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-02-06T15:41:25+00:00"
|
||||
"time": "2024-02-10T20:56:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/doctrine-migrations-bundle",
|
||||
|
@ -1484,16 +1484,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "1.10.57",
|
||||
"version": "1.10.58",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "1627b1d03446904aaa77593f370c5201d2ecc34e"
|
||||
"reference": "a23518379ec4defd9e47cbf81019526861623ec2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/1627b1d03446904aaa77593f370c5201d2ecc34e",
|
||||
"reference": "1627b1d03446904aaa77593f370c5201d2ecc34e",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/a23518379ec4defd9e47cbf81019526861623ec2",
|
||||
"reference": "a23518379ec4defd9e47cbf81019526861623ec2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1542,7 +1542,7 @@
|
|||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-01-24T11:51:34+00:00"
|
||||
"time": "2024-02-12T20:02:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/cache",
|
||||
|
@ -5219,16 +5219,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symplify/easy-coding-standard",
|
||||
"version": "12.1.10",
|
||||
"version": "12.1.11",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/easy-coding-standard/easy-coding-standard.git",
|
||||
"reference": "67f643befd6997961aa6bd759b4529e94bb18b53"
|
||||
"reference": "d8653e2f4ef154039841a7bfed4e91eb5deae1ab"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/67f643befd6997961aa6bd759b4529e94bb18b53",
|
||||
"reference": "67f643befd6997961aa6bd759b4529e94bb18b53",
|
||||
"url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/d8653e2f4ef154039841a7bfed4e91eb5deae1ab",
|
||||
"reference": "d8653e2f4ef154039841a7bfed4e91eb5deae1ab",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -5261,7 +5261,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/easy-coding-standard/easy-coding-standard/issues",
|
||||
"source": "https://github.com/easy-coding-standard/easy-coding-standard/tree/12.1.10"
|
||||
"source": "https://github.com/easy-coding-standard/easy-coding-standard/tree/12.1.11"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -5273,7 +5273,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2024-02-05T10:58:24+00:00"
|
||||
"time": "2024-02-13T11:35:41+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use App\Service\WhoAreYou;
|
||||
// config/packages/twig.php
|
||||
use Symfony\Config\TwigConfig;
|
||||
|
||||
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
|
||||
|
||||
use App\Service\WhoAreYou;
|
||||
|
||||
return static function (TwigConfig $twig): void {
|
||||
$twig
|
||||
->fileNamePattern('*.twig')
|
||||
$twig->fileNamePattern('*.twig')
|
||||
->global('username', service(WhoAreYou::class));
|
||||
|
||||
if ($_SERVER['APP_ENV'] === 'test') {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symfony\Bridge\Twig\AppVariable;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
|
|
@ -11,7 +11,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use DateTimeImmutable;
|
||||
|
||||
#[Route('/order')]
|
||||
class FoodOrderController extends AbstractController
|
||||
|
@ -29,7 +28,8 @@ class FoodOrderController extends AbstractController
|
|||
'food_order/show.html.twig',
|
||||
[
|
||||
'food_order' => $foodOrder,
|
||||
'menu_items' => $foodOrder->getVendor()->getMenuItems(),
|
||||
'menu_items' => $foodOrder->getVendor()
|
||||
->getMenuItems(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -62,17 +62,23 @@ class FoodOrderController extends AbstractController
|
|||
EntityManagerInterface $entityManager,
|
||||
Request $request,
|
||||
): Response {
|
||||
$orderItem = new OrderItem();
|
||||
$orderItem = new OrderItem;
|
||||
$orderItem->setFoodOrder($foodOrder);
|
||||
$orderItem->setMenuItem($menuItem);
|
||||
|
||||
$form = $this->createForm(OrderItemType::class, $orderItem, ['menuItem' => $menuItem]);
|
||||
$form = $this->createForm(
|
||||
OrderItemType::class,
|
||||
$orderItem,
|
||||
[
|
||||
'menuItem' => $menuItem,
|
||||
],
|
||||
);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->persist($orderItem);
|
||||
$entityManager->flush();
|
||||
return $this->redirectToRoute(
|
||||
FoodOrderController::APP_FOOD_ORDER_SHOW,
|
||||
self::APP_FOOD_ORDER_SHOW,
|
||||
[
|
||||
'id' => $foodOrder->getId(),
|
||||
],
|
||||
|
@ -80,13 +86,9 @@ class FoodOrderController extends AbstractController
|
|||
);
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
'food_order/orderitem.html.twig',
|
||||
[
|
||||
'form' => $form,
|
||||
],
|
||||
);
|
||||
|
||||
return $this->render('food_order/orderitem.html.twig', [
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route(
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\FoodOrder;
|
||||
use App\Form\FoodOrderType;
|
||||
use App\Repository\FoodOrderRepository;
|
||||
use App\Service\WhoAreYou;
|
||||
use App\Entity\FoodOrder;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
@ -23,7 +23,7 @@ final class Start extends AbstractController
|
|||
Request $request,
|
||||
): Response {
|
||||
$openOrders = $foodOrderRepository->findOpenOrders();
|
||||
$order = new FoodOrder();
|
||||
$order = new FoodOrder;
|
||||
$form = $this->createForm(FoodOrderType::class, $order);
|
||||
$form->handleRequest($request);
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Vendor;
|
||||
use App\Form\VendorType;
|
||||
use App\Repository\VendorRepository;
|
||||
use App\Entity\Vendor;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
|
@ -8,14 +8,22 @@ use App\Entity\MenuItemAlias;
|
|||
use App\Entity\Vendor;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Faker\Factory;
|
||||
use Faker\Generator;
|
||||
use Override;
|
||||
|
||||
use function random_int;
|
||||
use function range;
|
||||
|
||||
final class AppFixture extends Fixture
|
||||
{
|
||||
private Generator $faker;
|
||||
public function load(ObjectManager $manager)
|
||||
|
||||
#[Override]
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$this->faker = \Faker\Factory::create();
|
||||
$this->faker = Factory::create();
|
||||
|
||||
foreach (range(0, 20) as $vendorCount) {
|
||||
$this->createVendorAndMenuItems($manager);
|
||||
}
|
||||
|
@ -23,49 +31,33 @@ final class AppFixture extends Fixture
|
|||
$manager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MenuItem $menuItem
|
||||
* @param ObjectManager $manager
|
||||
* @return void
|
||||
*/
|
||||
public function addMenuItemAliases(MenuItem $menuItem, ObjectManager $manager): void
|
||||
{
|
||||
$menuItemAliasOne = new MenuItemAlias();
|
||||
public function addMenuItemAliases(
|
||||
MenuItem $menuItem,
|
||||
ObjectManager $manager,
|
||||
): void {
|
||||
$menuItemAliasOne = new MenuItemAlias;
|
||||
$menuItemAliasOne->setName($this->faker->word);
|
||||
$menuItem->addMenuItemAlias($menuItemAliasOne);
|
||||
$manager->persist($menuItemAliasOne);
|
||||
$menuItemAliasTwo = new MenuItemAlias();
|
||||
$menuItemAliasTwo = new MenuItemAlias;
|
||||
$menuItemAliasTwo->setName($this->faker->word);
|
||||
$menuItem->addMenuItemAlias($menuItemAliasTwo);
|
||||
$manager->persist($menuItemAliasTwo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MenuItem $menuItem
|
||||
* @param ObjectManager $manager
|
||||
* @return void
|
||||
* @throws \Random\RandomException
|
||||
*/
|
||||
public function addMenuItemExtras(MenuItem $menuItem, ObjectManager $manager): void
|
||||
{
|
||||
|
||||
foreach(range(0, random_int(0, 5)) as $dispose) {
|
||||
$itemExtra = new ItemExtra();
|
||||
foreach (range(0, random_int(0, 5)) as $dispose) {
|
||||
$itemExtra = new ItemExtra;
|
||||
$itemExtra->setName($this->faker->word);
|
||||
$menuItem->addItemExtra($itemExtra);
|
||||
$manager->persist($itemExtra);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Vendor $vendor
|
||||
* @param ObjectManager $manager
|
||||
* @return void
|
||||
* @throws \Random\RandomException
|
||||
*/
|
||||
public function createMenuItem(Vendor $vendor, ObjectManager $manager): void
|
||||
{
|
||||
$menuItem = new MenuItem();
|
||||
$menuItem = new MenuItem;
|
||||
$menuItem->setVendor($vendor);
|
||||
$menuItem->setPrice(random_int(500, 2000));
|
||||
$manager->persist($menuItem);
|
||||
|
@ -73,14 +65,9 @@ final class AppFixture extends Fixture
|
|||
$this->addMenuItemExtras($menuItem, $manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ObjectManager $manager
|
||||
* @return void
|
||||
* @throws \Random\RandomException
|
||||
*/
|
||||
public function createVendorAndMenuItems(ObjectManager $manager): void
|
||||
{
|
||||
$vendor = new Vendor();
|
||||
$vendor = new Vendor;
|
||||
$vendor->setName($this->faker->name);
|
||||
$manager->persist($vendor);
|
||||
|
||||
|
@ -88,4 +75,4 @@ final class AppFixture extends Fixture
|
|||
$this->createMenuItem($vendor, $manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\FoodOrderRepository;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
|
||||
use Symfony\Bridge\Doctrine\Types\UlidType;
|
||||
use Symfony\Component\Uid\Ulid;
|
||||
use DateTimeImmutable;
|
||||
|
||||
#[ORM\Entity(repositoryClass: FoodOrderRepository::class)]
|
||||
class FoodOrder
|
||||
|
@ -22,7 +21,7 @@ class FoodOrder
|
|||
private Ulid $id;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?DateTimeImmutable $closedAt = null;
|
||||
private DateTimeImmutable|null $closedAt = null;
|
||||
|
||||
#[ORM\Column(length: 30)]
|
||||
private string|null $startedBy = null;
|
||||
|
@ -39,8 +38,7 @@ class FoodOrder
|
|||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Vendor $vendor = null;
|
||||
|
||||
private Vendor|null $vendor = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -54,13 +52,14 @@ class FoodOrder
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
public function getClosedAt(): \DateTimeImmutable|null
|
||||
public function getClosedAt(): DateTimeImmutable|null
|
||||
{
|
||||
return $this->closedAt;
|
||||
}
|
||||
|
||||
public function setClosedAt(\DateTimeImmutable $closedAt = new DateTimeImmutable()): static
|
||||
{
|
||||
public function setClosedAt(
|
||||
DateTimeImmutable $closedAt = new DateTimeImmutable,
|
||||
): static {
|
||||
$this->closedAt = $closedAt;
|
||||
return $this;
|
||||
}
|
||||
|
@ -76,12 +75,12 @@ class FoodOrder
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getStartedAt(): \DateTimeImmutable
|
||||
public function getStartedAt(): DateTimeImmutable
|
||||
{
|
||||
return $this->startedAt;
|
||||
}
|
||||
|
||||
public function setStartedAt(\DateTimeImmutable $startedAt): static
|
||||
public function setStartedAt(DateTimeImmutable $startedAt): static
|
||||
{
|
||||
$this->startedAt = $startedAt;
|
||||
return $this;
|
||||
|
@ -118,23 +117,24 @@ class FoodOrder
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getVendor(): ?Vendor
|
||||
public function getVendor(): Vendor|null
|
||||
{
|
||||
return $this->vendor;
|
||||
}
|
||||
|
||||
public function setVendor(?Vendor $vendor): static
|
||||
public function setVendor(Vendor|null $vendor): static
|
||||
{
|
||||
$this->vendor = $vendor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function groupedOrderItems(): array
|
||||
{
|
||||
return $this->orderItems->reduce(
|
||||
function (array $carry, OrderItem $item): array {
|
||||
$menuItemStringId = (string)$item->getMenuItem()->getId();
|
||||
static function (array $carry, OrderItem $item): array {
|
||||
$menuItemStringId = (string) $item->getMenuItem()
|
||||
->getId();
|
||||
|
||||
if (isset($carry[$menuItemStringId])) {
|
||||
$carry[$menuItemStringId]['amount']++;
|
||||
} else {
|
||||
|
@ -143,11 +143,10 @@ class FoodOrder
|
|||
'amount' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
[],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
|
@ -11,7 +11,6 @@ use Symfony\Component\Uid\Ulid;
|
|||
#[ORM\Entity(repositoryClass: ItemExtraRepository::class)]
|
||||
class ItemExtra
|
||||
{
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\Column(type: UlidType::NAME, unique: true)]
|
||||
|
@ -19,13 +18,14 @@ class ItemExtra
|
|||
private Ulid $id;
|
||||
|
||||
#[ORM\Column(length: 50)]
|
||||
private ?string $name = null;
|
||||
private string|null $name = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'itemExtras')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?MenuItem $menuItem = null;
|
||||
private MenuItem|null $menuItem = null;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->id = new Ulid;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class ItemExtra
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
public function getName(): string|null
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
@ -42,19 +42,17 @@ class ItemExtra
|
|||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMenuItem(): ?MenuItem
|
||||
public function getMenuItem(): MenuItem|null
|
||||
{
|
||||
return $this->menuItem;
|
||||
}
|
||||
|
||||
public function setMenuItem(?MenuItem $menuItem): static
|
||||
public function setMenuItem(MenuItem|null $menuItem): static
|
||||
{
|
||||
$this->menuItem = $menuItem;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,14 +33,18 @@ class MenuItem
|
|||
)]
|
||||
private Collection $menuItemAliases;
|
||||
|
||||
#[ORM\OneToMany(mappedBy: 'menuItem', targetEntity: ItemExtra::class, orphanRemoval: true)]
|
||||
#[ORM\OneToMany(
|
||||
mappedBy: 'menuItem',
|
||||
targetEntity: ItemExtra::class,
|
||||
orphanRemoval: true,
|
||||
)]
|
||||
private Collection $itemExtras;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->id = new Ulid;
|
||||
$this->menuItemAliases = new ArrayCollection;
|
||||
$this->itemExtras = new ArrayCollection();
|
||||
$this->itemExtras = new ArrayCollection;
|
||||
}
|
||||
|
||||
public function getId(): Ulid
|
||||
|
@ -53,7 +57,7 @@ class MenuItem
|
|||
return $this->vendor;
|
||||
}
|
||||
|
||||
public function setVendor(Vendor$vendor): static
|
||||
public function setVendor(Vendor $vendor): static
|
||||
{
|
||||
$this->vendor = $vendor;
|
||||
return $this;
|
||||
|
@ -111,7 +115,7 @@ class MenuItem
|
|||
|
||||
public function addItemExtra(ItemExtra $itemExtra): static
|
||||
{
|
||||
if (!$this->itemExtras->contains($itemExtra)) {
|
||||
if (! $this->itemExtras->contains($itemExtra)) {
|
||||
$this->itemExtras->add($itemExtra);
|
||||
$itemExtra->setMenuItem($this);
|
||||
}
|
||||
|
@ -121,11 +125,12 @@ class MenuItem
|
|||
|
||||
public function removeItemExtra(ItemExtra $itemExtra): static
|
||||
{
|
||||
if ($this->itemExtras->removeElement($itemExtra)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($itemExtra->getMenuItem() === $this) {
|
||||
$itemExtra->setMenuItem(null);
|
||||
}
|
||||
// set the owning side to null (unless already changed)
|
||||
if (
|
||||
$this->itemExtras->removeElement($itemExtra)
|
||||
&& $itemExtra->getMenuItem() === $this
|
||||
) {
|
||||
$itemExtra->setMenuItem(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class OrderItem
|
|||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?MenuItem $menuItem = null;
|
||||
private MenuItem|null $menuItem = null;
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: ItemExtra::class, cascade: ['persist'])]
|
||||
private Collection $extras;
|
||||
|
@ -33,7 +33,7 @@ class OrderItem
|
|||
public function __construct()
|
||||
{
|
||||
$this->id = new Ulid;
|
||||
$this->extras = new ArrayCollection();
|
||||
$this->extras = new ArrayCollection;
|
||||
}
|
||||
|
||||
public function getId(): Ulid
|
||||
|
@ -52,15 +52,14 @@ class OrderItem
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getMenuItem(): ?MenuItem
|
||||
public function getMenuItem(): MenuItem|null
|
||||
{
|
||||
return $this->menuItem;
|
||||
}
|
||||
|
||||
public function setMenuItem(?MenuItem $menuItem): static
|
||||
public function setMenuItem(MenuItem|null $menuItem): static
|
||||
{
|
||||
$this->menuItem = $menuItem;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -74,7 +73,7 @@ class OrderItem
|
|||
|
||||
public function addExtra(ItemExtra $extra): static
|
||||
{
|
||||
if (!$this->extras->contains($extra)) {
|
||||
if (! $this->extras->contains($extra)) {
|
||||
$this->extras->add($extra);
|
||||
}
|
||||
|
||||
|
@ -84,8 +83,6 @@ class OrderItem
|
|||
public function removeExtra(ItemExtra $extra): static
|
||||
{
|
||||
$this->extras->removeElement($extra);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
|
@ -30,7 +29,6 @@ class Vendor
|
|||
)]
|
||||
private Collection $menuItems;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->id = new Ulid;
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Service\WhoAreYou;
|
||||
use App\Entity\FoodOrder;
|
||||
use App\Entity\Vendor;
|
||||
use App\Service\WhoAreYou;
|
||||
use Override;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
|
|
@ -1,42 +1,44 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\MenuItem;
|
||||
use App\Entity\ItemExtra;
|
||||
use App\Entity\MenuItem;
|
||||
use App\Entity\OrderItem;
|
||||
use Override;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
// ...
|
||||
|
||||
class OrderItemType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array{menuItem: MenuItem} $options
|
||||
* @return void
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
#[Override]
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('extras', EntityType::class, [
|
||||
$builder->add(
|
||||
'extras',
|
||||
EntityType::class,
|
||||
[
|
||||
'class' => ItemExtra::class,
|
||||
'choices' => $options['menuItem']->getItemExtras(),
|
||||
'choice_label' => 'name', // Change this for the field you want to display
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
]);
|
||||
'expanded' => true,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
#[Override]
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => OrderItem::class,
|
||||
]);
|
||||
|
||||
$resolver->setRequired('menuItem');
|
||||
$resolver->setAllowedTypes('menuItem', MenuItem::class);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
|
@ -27,7 +26,8 @@ class FoodOrderRepository extends ServiceEntityRepository
|
|||
*/
|
||||
public function findOpenOrders(): array
|
||||
{
|
||||
return $this->createQueryBuilder('f')
|
||||
return $this
|
||||
->createQueryBuilder('f')
|
||||
->andWhere('f.closedAt IS NULL')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
|
@ -21,28 +21,27 @@ class ItemExtraRepository extends ServiceEntityRepository
|
|||
parent::__construct($registry, ItemExtra::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return ItemExtra[] Returns an array of ItemExtra objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('i')
|
||||
// ->andWhere('i.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('i.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?ItemExtra
|
||||
// {
|
||||
// return $this->createQueryBuilder('i')
|
||||
// ->andWhere('i.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
// /**
|
||||
// * @return ItemExtra[] Returns an array of ItemExtra objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('i')
|
||||
// ->andWhere('i.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('i.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
// public function findOneBySomeField($value): ?ItemExtra
|
||||
// {
|
||||
// return $this->createQueryBuilder('i')
|
||||
// ->andWhere('i.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Twig;
|
||||
|
||||
use Override;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
|
||||
use function number_format;
|
||||
|
||||
use Override;
|
||||
|
||||
final class AppExtension extends AbstractExtension
|
||||
{
|
||||
#[Override]
|
||||
|
|
22
symfony.lock
22
symfony.lock
|
@ -25,6 +25,19 @@
|
|||
"src/DataFixtures/AppFixtures.php"
|
||||
]
|
||||
},
|
||||
"doctrine/doctrine-migrations-bundle": {
|
||||
"version": "3.3",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "3.1",
|
||||
"ref": "1d01ec03c6ecbd67c3375c5478c9a423ae5d6a33"
|
||||
},
|
||||
"files": [
|
||||
"config/packages/doctrine_migrations.yaml",
|
||||
"migrations/.gitignore"
|
||||
]
|
||||
},
|
||||
"phpstan/phpstan": {
|
||||
"version": "1.10",
|
||||
"recipe": {
|
||||
|
@ -86,6 +99,15 @@
|
|||
"src/Kernel.php"
|
||||
]
|
||||
},
|
||||
"symfony/maker-bundle": {
|
||||
"version": "1.54",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "1.0",
|
||||
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
|
||||
}
|
||||
},
|
||||
"symfony/routing": {
|
||||
"version": "7.0",
|
||||
"recipe": {
|
||||
|
|
Loading…
Reference in a new issue