src/EventSubscriber/Product/ProductSymbolResourceSubscriber.php line 25

  1. <?php
  2. namespace App\EventSubscriber\Product;
  3. use Symfony\Component\HttpFoundation\RequestStack;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\EventDispatcher\GenericEvent;
  6. use Webmozart\Assert\Assert;
  7. use Sylius\Component\Customer\Model\CustomerInterface;
  8. use App\Repository\Customer\CustomerRepository;
  9. use App\Entity\Channel\ChannelEcodaAccountInfo;
  10. use App\Entity\Product\ProductSymbol;
  11. use App\Repository\Channel\ChannelEcodaAccountInfoRepository;
  12. use App\Repository\Channel\ChannelEcodaAccountTypeRepository;
  13. use Doctrine\ORM\EntityManagerInterface;
  14. use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  15. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  16. use App\Manager\EcodaAccountManager;
  17. use App\Entity\Product\ProductVariant;
  18. class ProductSymbolResourceSubscriber  implements EventSubscriberInterface
  19. { 
  20.      
  21.     public function onAppEntityPreCreate(GenericEvent $event)
  22.     {  
  23.         $entity = $event->getSubject();  
  24.         Assert::isInstanceOf($entity, ProductSymbol::class);  
  25.     } 
  26.     public function onAppEntityPreUpdate(GenericEvent $event)
  27.     {   
  28.         $entity = $event->getSubject();  
  29.         Assert::isInstanceOf($entity, ProductSymbol::class);  
  30.     } 
  31.  
  32.     public static function getSubscribedEvents()
  33.     {
  34.         return [
  35.            'app.product_symbol.pre_create' => 'onAppEntityPreCreate', 
  36.            'app.product_symbol.pre_update' => 'onAppEntityPreUpdate', 
  37.         ];
  38.     }
  39. }