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>
<option name="path" value="$PROJECT_DIR$/tests" />
</Configuration>
<Configuration>
<option name="path" value="$PROJECT_DIR$/tests" />
</Configuration>
</list>
</option>
</component>

View file

@ -35,6 +35,9 @@
<PhpSpecSuiteConfiguration>
<option name="myPath" value="$PROJECT_DIR$" />
</PhpSpecSuiteConfiguration>
<PhpSpecSuiteConfiguration>
<option name="myPath" value="$PROJECT_DIR$" />
</PhpSpecSuiteConfiguration>
</suites>
</component>
</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\MenuItem;
use App\Entity\OrderItem;
use App\Form\MenuItemExtraType;
use App\Form\OrderItemType;
use App\Repository\ItemExtraRepository;
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,
'extras' => $extraRepository->getUniqueNames(),
]);
],
);
}
#[Route(

View file

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

View file

@ -8,7 +8,6 @@ use App\Entity\OrderItem;
use Override;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

View file

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