src/Knitink/ManagementBundle/Listener/GatewaySubscriber.php line 37

Open in your IDE?
  1. <?php
  2. namespace Knitink\ManagementBundle\Listener;
  3. use Knitink\ManagementBundle\Domain\GatewayManager;
  4. use Knitink\ManagementBundle\Domain\LicenseModuleManager;
  5. use Knitink\ManagementBundle\Domain\LicenseUnitManager;
  6. use Knitink\ManagementBundle\Domain\UnitManager;
  7. use Knitink\ManagementBundle\Entity\DBAL\StatusType;
  8. use Knitink\ManagementBundle\Entity\Historial;
  9. use Knitink\ManagementBundle\Event\GatewayEvent;
  10. use Knitink\ManagementBundle\Event\TeamEvent;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. class GatewaySubscriber implements EventSubscriberInterface
  13. {
  14.     public function __construct()
  15.     {
  16.     }
  17.     /**
  18.      * @inheritDoc
  19.      */
  20.     public static function getSubscribedEvents()
  21.     {
  22.         return [
  23.             GatewayEvent::CREATE_SUCCESS => 'onCreateSuccess',
  24.             GatewayEvent::CREATE_COMPLETED => 'onCreateCompleted',
  25.             GatewayEvent::EDIT_SUCCESS => 'onEditSuccess',
  26.             GatewayEvent::EDIT_COMPLETED => 'onEditCompleted',
  27.             GatewayEvent::ACTIVATE_COMPLETED => 'onActivateCompleted'
  28.         ];
  29.     }
  30.     public function onCreateSuccess(GatewayEvent $event)
  31.     {
  32.     }
  33.     public function onCreateCompleted(GatewayEvent $event)
  34.     {
  35.         /*
  36.         $historial = new Historial();
  37.         $historial->setGateway($entity);
  38.         $historial->setTeam(null);
  39.         $historial->setClient(null);
  40.         $historial->setDealer($entity->getDealer());
  41.         $historial->setStatus(StatusType::ACTIVE);
  42.         $historial->setDoneBy($this->getUser());
  43.         $historial->setMessage("STR_REGISTER");
  44.         $em->persist($historial);
  45.         */
  46.         /*
  47.          *
  48.          * CONTROLLER API
  49.          $historial = new Historial();
  50.             $historial->setGateway($gateway);
  51.             $historial->setStatus(StatusType::ACTIVE);
  52.             $historial->setDoneBy($this->getUser());
  53.             $historial->setMessage("STR_REGISTER");
  54.          */
  55.     }
  56.     public function onEditSuccess(GatewayEvent $event)
  57.     {
  58.     }
  59.     public function onEditCompleted(GatewayEvent $event)
  60.     {
  61.         /*
  62.         $dealerPrevious = $entity->getDealer();
  63.         $dealer = $entity->getDealer();
  64.         if($dealer != null && $dealerPrevious == null){
  65.             $historial = new Historial();
  66.             $historial->setGateway($entity);
  67.             $historial->setDealer($entity->getDealer());
  68.             $historial->setStatus(StatusType::ACTIVE);
  69.             $historial->setDoneBy($this->getUser());
  70.             $historial->setMessage("STR_SUBSCRIBE_DEALER");
  71.             $em->persist($historial);
  72.         }else if($dealer != null && $dealerPrevious != null && $dealer->getId() != $dealerPrevious->getId()){
  73.             $historial = new Historial();
  74.             $historial->setGateway($entity);
  75.             $historial->setDealer($entity->getDealer());
  76.             $historial->setStatus(StatusType::ACTIVE);
  77.             $historial->setDoneBy($this->getUser());
  78.             $historial->setMessage("STR_CHANGE_DEALER");
  79.             $em->persist($historial);
  80.         }
  81.         */
  82.         /*
  83.          * CONTROLLER API
  84.           $historial = new Historial();
  85.             $historial->setGateway($gateway);
  86.             $historial->setStatus(StatusType::ACTIVE);
  87.             $historial->setDoneBy($this->getUser());
  88.             $historial->setMessage("STR_REPAIR");
  89.          */
  90.     }
  91.     public function onActivateCompleted(GatewayEvent $event)
  92.     {
  93.         /*
  94.         $historial = new Historial();
  95.         $historial->setGateway($entity);
  96.         $historial->setTeam(null);
  97.         $historial->setClient(null);
  98.         $historial->setDealer($entity->getDealer());
  99.         $historial->setStatus(StatusType::ACTIVE);
  100.         $historial->setDoneBy($this->getUser());
  101.         $historial->setMessage("STR_ACTIVATE");
  102.         $em->persist($historial);
  103.         */
  104.     }
  105. }