Skip to content

Commit

Permalink
Added check so you can't reserve products from sale sessions not visi…
Browse files Browse the repository at this point in the history
…ble due to reservation_trashold configuration
  • Loading branch information
d1ff1cult0 committed Nov 4, 2024
1 parent 74d5a3c commit 9459161
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 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()){

Check failure on line 34 in module/ShopBundle/Controller/ShopController.php

View workflow job for this annotation

GitHub Actions / Lint

Expected 1 space after IF keyword; 0 found

Check failure on line 34 in module/ShopBundle/Controller/ShopController.php

View workflow job for this annotation

GitHub Actions / Lint

Expected 1 space after closing parenthesis; found 0

Check failure on line 34 in module/ShopBundle/Controller/ShopController.php

View workflow job for this annotation

GitHub Actions / Lint

There must be a single space between the closing parenthesis and the opening brace of a multi-line IF statement; found 0 spaces
$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,14 @@ private function getStockEntries($salesSession)
)
);
}

private function saleSessionIsOpen(){

Check failure on line 558 in module/ShopBundle/Controller/ShopController.php

View workflow job for this annotation

GitHub Actions / Lint

Opening brace should be on a new line
$salesSessionId = $this->getSalesSessionEntity()->getId();
$openSaleSessions = $this->getSalesSessions();
$openSaleSessionsIds = array_map(function($session) {

Check failure on line 561 in module/ShopBundle/Controller/ShopController.php

View workflow job for this annotation

GitHub Actions / Lint

Opening parenthesis of a multi-line function call must be the last content on the line

Check failure on line 561 in module/ShopBundle/Controller/ShopController.php

View workflow job for this annotation

GitHub Actions / Lint

Expected 1 space after FUNCTION keyword; 0 found
return $session->getId();
}, $openSaleSessions);

Check failure on line 563 in module/ShopBundle/Controller/ShopController.php

View workflow job for this annotation

GitHub Actions / Lint

Only one argument is allowed per line in a multi-line function call

Check failure on line 563 in module/ShopBundle/Controller/ShopController.php

View workflow job for this annotation

GitHub Actions / Lint

Closing parenthesis of a multi-line function call must be on a line by itself

return in_array($salesSessionId, $openSaleSessionsIds);
}
}

0 comments on commit 9459161

Please sign in to comment.