<?php declare(strict_types=1);
namespace ImnxxCrmBlackoutScenario\Subscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Storefront\Page\GenericPageLoadedEvent;
use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
use Shopware\Storefront\Page\Checkout\Register\CheckoutRegisterPageLoadedEvent;
use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
use Shopware\Storefront\Page\Checkout\Finish\CheckoutFinishPageLoadedEvent;
use Shopware\Storefront\Page\Checkout\Cart\CheckoutCartPageLoadedEvent;
use Shopware\Storefront\Page\Checkout\Offcanvas\OffcanvasCartPageLoadedEvent;
use Shopware\Storefront\Page\Address\Listing\AddressListingPageLoadedEvent;
use Shopware\Storefront\Page\Address\Detail\AddressDetailPageLoadedEvent;
use Shopware\Storefront\Page\Account\Overview\AccountOverviewPageLoadedEvent;
use Shopware\Core\Checkout\Customer\Event\CustomerRegisterEvent;
use Shopware\Core\Checkout\Cart\Event\LineItemAddedEvent;
use Shopware\Storefront\Page\Search\SearchPageLoadedEvent;
use Symfony\Component\HttpFoundation\Session\Session;
class CrmBlackoutScenarioSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents(): array {
return [
GenericPageLoadedEvent::class => 'onPageLoaded',
];
}
public function onPageLoaded(GenericPageLoadedEvent $event) {
if (isset($_SESSION['crm_online'])) {
if ($_SESSION['crm_online'] === false || $_SESSION['crm_online'] === null) {
$crm_online_status['crm_online'] = false;
$event->getPage()->assign($crm_online_status);
}
$event->getPage()->assign(['crm_online' => $_SESSION['crm_online']]);
} else {
$event->getPage()->assign(['crm_online' => true]);
}
}
}