#20_save-username-to-cookie #24

Merged
lubiana merged 3 commits from #20_save-username-to-cookie into main 2024-06-30 07:58:09 +00:00
4 changed files with 7 additions and 0 deletions
Showing only changes of commit 70041d7357 - Show all commits

View file

@ -26,6 +26,8 @@ final class FoodOrderController extends AbstractController
public function new(Request $request, EntityManagerInterface $entityManager): Response public function new(Request $request, EntityManagerInterface $entityManager): Response
{ {
$foodOrder = new FoodOrder; $foodOrder = new FoodOrder;
$username = $request->cookies->get('username', 'nobody');
$foodOrder->setCreatedBy($username);
$form = $this->createForm(FoodOrderType::class, $foodOrder, [ $form = $this->createForm(FoodOrderType::class, $foodOrder, [
'action' => $this->generateUrl('app_food_order_new'), 'action' => $this->generateUrl('app_food_order_new'),
]); ]);

View file

@ -26,6 +26,9 @@ final class OrderItemController extends AbstractController
} }
$orderItem = new OrderItem; $orderItem = new OrderItem;
$username = $request->cookies->get('username', 'nobody');
$orderItem->setCreatedBy($username);
$form = $this->createForm(OrderItemType::class, $orderItem); $form = $this->createForm(OrderItemType::class, $orderItem);
$form->handleRequest($request); $form->handleRequest($request);

View file

@ -24,6 +24,7 @@ final class FoodOrderType extends AbstractType
->add(child: 'closedAt', options: [ ->add(child: 'closedAt', options: [
'label' => 'closes at', 'label' => 'closes at',
]) ])
->add(child: 'createdBy')
; ;
if ($action !== null) { if ($action !== null) {
$builder->setAction($action); $builder->setAction($action);

View file

@ -18,6 +18,7 @@ final class OrderItemType extends AbstractType
'data' => $options['name'] ?? '', 'data' => $options['name'] ?? '',
]) ])
->add('extras') ->add('extras')
->add('createdBy')
; ;
} }