|
@@ -2,20 +2,23 @@
|
|
|
|
|
|
namespace FTTHBundle\EventListener;
|
|
|
|
|
|
-use Doctrine\Common\EventSubscriber;
|
|
|
-use Doctrine\ORM\Event\LifecycleEventArgs;
|
|
|
-use Base\AdminBundle\Controller\TenancyService;
|
|
|
use FTTHBundle\Entity\ONU;
|
|
|
-use FTTHBundle\Entity\ONUProfile;
|
|
|
use FTTHBundle\Entity\VLanID;
|
|
|
+use FTTHBundle\Entity\ONUProfile;
|
|
|
+use FTTHBundle\Entity\ServicePort;
|
|
|
use FTTHBundle\Entity\VLanProfile;
|
|
|
use FTTHBundle\Entity\TContProfile;
|
|
|
+use Doctrine\Common\EventSubscriber;
|
|
|
use FTTHBundle\Entity\TrafficProfile;
|
|
|
-use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
|
|
-use Symfony\Component\Translation\TranslatorInterface;
|
|
|
+use FTTHBundle\Factory\ExceptionFactory;
|
|
|
use WorkflowBundle\Utils\DoctrineEvents;
|
|
|
-
|
|
|
-use FTTHBundle\Entity\ServicePort;
|
|
|
+use Doctrine\ORM\Event\LifecycleEventArgs;
|
|
|
+use FTTHBundle\Service\ClientProxyService;
|
|
|
+use Base\AdminBundle\Controller\TenancyService;
|
|
|
+use Exception;
|
|
|
+use Symfony\Component\Translation\TranslatorInterface;
|
|
|
+use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
+use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
|
|
|
|
|
class ONUSubscriber implements EventSubscriber
|
|
|
{
|
|
@@ -40,17 +43,24 @@ class ONUSubscriber implements EventSubscriber
|
|
|
*/
|
|
|
private $tenancyService;
|
|
|
|
|
|
+ /**
|
|
|
+ * @var ContainerInterface
|
|
|
+ */
|
|
|
+ private $containerInterface;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @param SessionInterface $session
|
|
|
* @param TranslatorInterface $translator
|
|
|
* @param TenancyService $tenancyService
|
|
|
+ * @param ContainerInterface $containerInterface
|
|
|
*/
|
|
|
- public function __construct(SessionInterface $session, TranslatorInterface $translator, TenancyService $tenancyService)
|
|
|
+ public function __construct(SessionInterface $session, TranslatorInterface $translator, TenancyService $tenancyService, ContainerInterface $containerInterface)
|
|
|
{
|
|
|
$this->session = $session;
|
|
|
$this->translator = $translator;
|
|
|
$this->tenancyService = $tenancyService;
|
|
|
+ $this->containerInterface = $containerInterface;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -73,6 +83,15 @@ class ONUSubscriber implements EventSubscriber
|
|
|
public function prePersist(LifecycleEventArgs $args)
|
|
|
{
|
|
|
$this->execute($args, DoctrineEvents::PRE_PERSIST);
|
|
|
+
|
|
|
+ try{
|
|
|
+ $entity = $args->getEntity();
|
|
|
+ if($entity instanceof ONU){
|
|
|
+ $this->setStateOnu($entity);
|
|
|
+ }
|
|
|
+ }catch(Exception $ex){
|
|
|
+ ExceptionFactory::make($ex->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -95,6 +114,15 @@ class ONUSubscriber implements EventSubscriber
|
|
|
public function preUpdate(LifecycleEventArgs $args)
|
|
|
{
|
|
|
$this->execute($args, DoctrineEvents::PRE_UPDATE);
|
|
|
+
|
|
|
+ try{
|
|
|
+ $entity = $args->getEntity();
|
|
|
+ if($entity instanceof ONU){
|
|
|
+ $this->setStateOnu($entity);
|
|
|
+ }
|
|
|
+ }catch(Exception $ex){
|
|
|
+ ExceptionFactory::make($ex->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -274,6 +302,15 @@ class ONUSubscriber implements EventSubscriber
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function setStateOnu($onu){
|
|
|
+ try{
|
|
|
+ $clientProxyService = new ClientProxyService($this->containerInterface->get('webservice'), $this->containerInterface);
|
|
|
+ $clientProxyService->setStateOnu($onu);
|
|
|
+ } catch (Exception $ex){
|
|
|
+ ExceptionFactory::make($ex->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Calcula dos ServicePort para t com
|
|
|
*
|