<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
declare(strict_types=1);
namespace scha1\scha1HidePriceInProducts\Subscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Storefront\Event\StorefrontRenderEvent;
use scha1\scha1HidePriceInProducts\Service\Service;
class Frontend implements EventSubscriberInterface{
/**
*
* @var $Service
*/
private $Service;
/**
*
* @param Service $service
*/
public function __construct(Service $service) {
$this->Service = $service;
}
/**
*
* @return array
*/
public static function getSubscribedEvents(): array {
return[
StorefrontRenderEvent::class => 'onStorefrontRender'
];
}
/**
*
* @param StorefrontRenderEvent $event
* @return
*/
public function onStorefrontRender(StorefrontRenderEvent $event) {
$active = (bool)$this->Service->getPluginConfig('disabled');
if ($active == 1) {
return $event->setParameter('active', $active );
} else {
return;
}
}
}