Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIPRES-261: Restrict BO subscription list for all shops #823

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Adapter/Shop.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public function getShop(): \Shop
return \Context::getContext()->shop;
}

public function getContext()
public function getContext(): int
{
return $this->getShop()->getContext();
return (int) $this->getShop()->getContext();
}
}
13 changes: 13 additions & 0 deletions subscription/Controller/Symfony/SubscriptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Mollie\Subscription\Controller\Symfony;

use Exception;
use Mollie\Adapter\Shop;
use Mollie\Subscription\Exception\SubscriptionApiException;
use Mollie\Subscription\Filters\SubscriptionFilters;
use Mollie\Subscription\Grid\SubscriptionGridDefinitionFactory;
Expand All @@ -28,6 +29,17 @@ class SubscriptionController extends AbstractSymfonyController
*/
public function indexAction(SubscriptionFilters $filters, Request $request)
{
/** @var Shop $shop */
$shop = $this->leagueContainer->getService(Shop::class);

if ($shop->getContext() !== \Shop::CONTEXT_SHOP) {
if (!$this->get('session')->getFlashBag()->has('error')) {
$this->addFlash('error', $this->module->l('Select the shop that you want to configure'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure trans should be used here?

}

return $this->render('@PrestaShop/Admin/layout.html.twig');
}

/** @var GridFactoryInterface $currencyGridFactory */
$currencyGridFactory = $this->leagueContainer->getService('subscription_grid_factory');
$currencyGrid = $currencyGridFactory->getGrid($filters);
Expand Down Expand Up @@ -71,6 +83,7 @@ public function cancelAction(int $subscriptionId): RedirectResponse
{
/** @var SubscriptionCancellationHandler $subscriptionCancellationHandler */
$subscriptionCancellationHandler = $this->leagueContainer->getService(SubscriptionCancellationHandler::class);

try {
$subscriptionCancellationHandler->handle($subscriptionId);
} catch (SubscriptionApiException $e) {
Expand Down
Loading