Skip to content

Commit

Permalink
Merge branch 'master' into vtk-master
Browse files Browse the repository at this point in the history
  • Loading branch information
d1ff1cult0 committed Nov 4, 2024
2 parents 7cb4141 + 019f6af commit 3679a38
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions module/ShopBundle/Controller/ShopController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -546,4 +554,18 @@ 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);
}
}

0 comments on commit 3679a38

Please sign in to comment.