src/Knitink/ManagementBundle/Listener/TeamSubscriber.php line 28

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\TeamEvent;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. class TeamSubscriber implements EventSubscriberInterface
  12. {
  13.     public function __construct()
  14.     {
  15.     }
  16.     /**
  17.      * @inheritDoc
  18.      */
  19.     public static function getSubscribedEvents()
  20.     {
  21.         return [
  22.             TeamEvent::CREATE_SUCCESS => 'onCreateSuccess',
  23.             TeamEvent::CREATE_COMPLETED => 'onCreateCompleted',
  24.             TeamEvent::EDIT_SUCCESS => 'onEditSuccess',
  25.             TeamEvent::EDIT_COMPLETED => 'onEditCompleted'
  26.         ];
  27.     }
  28.     public function onCreateSuccess(TeamEvent $event) {
  29.         $team $event->getTeam();
  30.         $form $event->getForm();
  31.     }
  32.     public function onCreateCompleted(TeamEvent $event) {
  33.         $team $event->getTeam();
  34.         $form $event->getForm();
  35.         /*
  36.            $historial = new Historial();
  37.            $historial->setUnit($master);
  38.            $historial->setTeam($master->getTeam());
  39.            $historial->setClient($master->getClient());
  40.            $historial->setDealer($master->getDealer());
  41.            $historial->setStatus(StatusType::ACTIVE);
  42.            $historial->setDoneBy($this->getUser());
  43.            $historial->setMessage("STR_SUBSCRIBE_TEAM");
  44.            $em->persist($historial);
  45.            */
  46.         /*
  47.            $historial = new Historial();
  48.            $historial->setGateway($gateway);
  49.            $historial->setTeam($gateway->getTeam());
  50.            $historial->setClient($gateway->getClient());
  51.            $historial->setDealer($gateway->getDealer());
  52.            $historial->setStatus(StatusType::ACTIVE);
  53.            $historial->setDoneBy($this->getUser());
  54.            $historial->setMessage("STR_SUBSCRIBE_TEAM");
  55.            $em->persist($historial);
  56.            */
  57.     }
  58.     public function onEditSuccess(TeamEvent $event) {
  59.         $form $event->getForm();
  60.     }
  61.     public function onEditCompleted(TeamEvent $event) {
  62.         $team $event->getTeam();
  63.         /*
  64.         $stock = $dealer->getLicenseByItem($type);
  65.         // Vemos si tienen licencias libres para ese tipo de Master
  66.         if($stock == null || $stock->getFree() <= 0){
  67.             $object->setMaster(null);
  68.             //$this->addFlash('error', 'STR_MASTER_CREATE_NO_PERMISSION');
  69.             //$tab = "edit";
  70.         }else {
  71.             $stock->addUsed();
  72.             if($unitReadonly == false){
  73.                 $historial = new Historial();
  74.                 $historial->setUnit($master);
  75.                 $historial->setTeam($master->getTeam());
  76.                 $historial->setClient($master->getClient());
  77.                 $historial->setDealer($master->getDealer());
  78.                 $historial->setStatus(StatusType::ACTIVE);
  79.                 $historial->setDoneBy($this->getUser());
  80.                 $historial->setMessage("STR_SUBSCRIBE_TEAM");
  81.                 $em->persist($historial);
  82.             }
  83.             */
  84.         /*
  85.         if($gatewayReadonly == false) {
  86.             $historial = new Historial();
  87.             $historial->setGateway($gateway);
  88.             $historial->setTeam($gateway->getTeam());
  89.             $historial->setClient($gateway->getClient());
  90.             $historial->setDealer($gateway->getDealer());
  91.             $historial->setStatus(StatusType::ACTIVE);
  92.             $historial->setDoneBy($this->getUser());
  93.             $historial->setMessage("STR_SUBSCRIBE_TEAM");
  94.             $em->persist($historial);
  95.         }
  96.         */
  97.     }
  98. }