custom/plugins/scha1HidePriceInProducts/src/Subscriber/Frontend.php line 46

Open in your IDE?
  1. <?php
  2. /* 
  3.  * To change this license header, choose License Headers in Project Properties.
  4.  * To change this template file, choose Tools | Templates
  5.  * and open the template in the editor.
  6.  */
  7. declare(strict_types=1);
  8. namespace scha1\scha1HidePriceInProducts\Subscriber;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. use Shopware\Storefront\Event\StorefrontRenderEvent;
  11. use scha1\scha1HidePriceInProducts\Service\Service;
  12. class Frontend implements EventSubscriberInterface{
  13.   
  14.   /**
  15.   *
  16.   * @var $Service
  17.   */
  18.   private $Service;
  19.   
  20.   /**
  21.    * 
  22.    * @param Service $service
  23.    */
  24.   public function __construct(Service $service) {
  25.     $this->Service $service;
  26.   }
  27.   
  28.   /**
  29.    * 
  30.    * @return array
  31.    */
  32.   public static function getSubscribedEvents(): array {
  33.     return[
  34.       StorefrontRenderEvent::class => 'onStorefrontRender'
  35.     ];
  36.   }
  37.   
  38.   /**
  39.    * 
  40.    * @param StorefrontRenderEvent $event
  41.    * @return
  42.    */
  43.   public function onStorefrontRender(StorefrontRenderEvent $event) {
  44.     $active = (bool)$this->Service->getPluginConfig('disabled');
  45.     if ($active == 1) {
  46.       return $event->setParameter('active'$active );
  47.     } else {
  48.       return;
  49.     }
  50.   }
  51. }