This commit is contained in:
Jonas 2024-03-06 18:00:50 +01:00
parent 3d6809830c
commit fe9820ef4b
7 changed files with 253 additions and 234 deletions

View file

@ -36,6 +36,9 @@
<Configuration> <Configuration>
<option name="path" value="$PROJECT_DIR$/tests" /> <option name="path" value="$PROJECT_DIR$/tests" />
</Configuration> </Configuration>
<Configuration>
<option name="path" value="$PROJECT_DIR$/tests" />
</Configuration>
</list> </list>
</option> </option>
</component> </component>

View file

@ -35,6 +35,9 @@
<PhpSpecSuiteConfiguration> <PhpSpecSuiteConfiguration>
<option name="myPath" value="$PROJECT_DIR$" /> <option name="myPath" value="$PROJECT_DIR$" />
</PhpSpecSuiteConfiguration> </PhpSpecSuiteConfiguration>
<PhpSpecSuiteConfiguration>
<option name="myPath" value="$PROJECT_DIR$" />
</PhpSpecSuiteConfiguration>
</suites> </suites>
</component> </component>
</project> </project>

434
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -5,6 +5,7 @@ namespace App\Controller;
use App\Entity\FoodOrder; use App\Entity\FoodOrder;
use App\Entity\MenuItem; use App\Entity\MenuItem;
use App\Entity\OrderItem; use App\Entity\OrderItem;
use App\Form\MenuItemExtraType;
use App\Form\OrderItemType; use App\Form\OrderItemType;
use App\Repository\ItemExtraRepository; use App\Repository\ItemExtraRepository;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -88,10 +89,18 @@ class FoodOrderController extends AbstractController
); );
} }
return $this->render('food_order/orderitem.html.twig', [ $formExtra = $this->createForm(
MenuItemExtraType::class,
);
return $this->render(
'food_order/orderitem.html.twig',
[
'form' => $form, 'form' => $form,
'extras' => $extraRepository->getUniqueNames(), 'extras' => $extraRepository->getUniqueNames(),
]); ],
);
} }
#[Route( #[Route(

View file

@ -1,10 +1,10 @@
<?php <?php
declare(strict_types=1);
namespace App\Form; namespace App\Form;
use App\Entity\ItemExtra; use App\Entity\ItemExtra;
use App\Entity\MenuItem; use Override;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
@ -12,18 +12,25 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class MenuItemExtraType extends AbstractType class MenuItemExtraType extends AbstractType
{ {
#[Override]
public function buildForm(FormBuilderInterface $builder, array $options): void public function buildForm(FormBuilderInterface $builder, array $options): void
{ {
$builder $builder->add('name');
->add('name'); $builder->add(
$builder->add('customextra', TextType::class, [ 'customextra',
TextType::class,
[
'label' => 'Add a new extra option', 'label' => 'Add a new extra option',
'mapped' => false, 'mapped' => false,
'required' => false, 'required' => false,
'attr' => ['list' => 'item-extra-list'], 'attr' => [
]); 'list' => 'item-extra-list',
],
],
);
} }
#[\Override]
public function configureOptions(OptionsResolver $resolver): void public function configureOptions(OptionsResolver $resolver): void
{ {
$resolver->setDefaults([ $resolver->setDefaults([

View file

@ -8,7 +8,6 @@ use App\Entity\OrderItem;
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;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;

View file

@ -26,9 +26,7 @@ class ItemExtraRepository extends ServiceEntityRepository
public function getUniqueNames(): Collection public function getUniqueNames(): Collection
{ {
$qb = $this->createQueryBuilder('p'); $qb = $this->createQueryBuilder('p');
$qb->groupBy('p.name'); $qb->groupBy('p.name');
return new ArrayCollection($qb->getQuery()->getResult()); return new ArrayCollection($qb->getQuery()->getResult());
} }
} }