diff --git a/module/ShopBundle/Controller/ShopController.php b/module/ShopBundle/Controller/ShopController.php index 7253ffd1e..c6b98d63f 100644 --- a/module/ShopBundle/Controller/ShopController.php +++ b/module/ShopBundle/Controller/ShopController.php @@ -31,6 +31,14 @@ public function reserveproductsAction() ); } + if(!$this->saleSessionIsOpen()){ + $this->flashMessenger()->error( + 'Error', + 'No session was found!' + ); + $this->redirect()->toRoute('shop'); + } + $salesSession = $this->getSalesSessionEntity(); $stockEntries = $this->getStockEntries($salesSession); @@ -546,4 +554,14 @@ private function getStockEntries($salesSession) ) ); } + + private function saleSessionIsOpen(){ + $salesSessionId = $this->getSalesSessionEntity()->getId(); + $openSaleSessions = $this->getSalesSessions(); + $openSaleSessionsIds = array_map(function($session) { + return $session->getId(); + }, $openSaleSessions); + + return in_array($salesSessionId, $openSaleSessionsIds); + } }