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