|
@@ -59,10 +59,11 @@ class ONUSubscriber implements EventSubscriber
|
|
|
{
|
|
|
$this->execute($args, DoctrineEvents::PRE_PERSIST);
|
|
|
|
|
|
+ $entity = $args->getEntity();
|
|
|
if ($entity instanceof ONU) {
|
|
|
- $this->assignTrafficProfile($args, DoctrineEvents::PRE_PERSIST)
|
|
|
- $this->assignTConProfile($args, DoctrineEvents::PRE_PERSIST)
|
|
|
- $this->assignVLanId($args, DoctrineEvents::PRE_PERSIST)
|
|
|
+ if(!$entity->getTrafficProfile()) $this->assignTrafficProfile($args, DoctrineEvents::PRE_PERSIST);
|
|
|
+ if(!$entity->getTcontprofile()) $this->assignTConProfile($args, DoctrineEvents::PRE_PERSIST);
|
|
|
+ if(!$entity->getVlan()) $this->assignVLanId($args, DoctrineEvents::PRE_PERSIST);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -87,20 +88,33 @@ class ONUSubscriber implements EventSubscriber
|
|
|
{
|
|
|
$this->execute($args, DoctrineEvents::PRE_UPDATE);
|
|
|
|
|
|
+ $entity = $args->getEntity();
|
|
|
if ($entity instanceof ONU) {
|
|
|
- $this->assignTrafficProfile($args, DoctrineEvents::PRE_UPDATE)
|
|
|
- $this->assignTConProfile($args, DoctrineEvents::PRE_UPDATE)
|
|
|
- $this->assignVLanId($args, DoctrineEvents::PRE_UPDATE)
|
|
|
+ if(!$entity->getTrafficProfile()) $this->assignTrafficProfile($args, DoctrineEvents::PRE_PERSIST);
|
|
|
+ if(!$entity->getTcontprofile()) $this->assignTConProfile($args, DoctrineEvents::PRE_PERSIST);
|
|
|
+ if(!$entity->getVlan()) $this->assignVLanId($args, DoctrineEvents::PRE_PERSIST);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function assignTrafficProfile(LifecycleEventArgs $args, $eventName = DoctrineEvents::PRE_PERSIST)
|
|
|
+ public function assignTrafficProfile(LifecycleEventArgs $args, $eventName = DoctrineEvents::PRE_PERSIST){
|
|
|
+ $obj = $args->getEntityManager()->getRepository("FTTHBundle:TrafficProfile")->findOneBy( array("used_by_default" => true));
|
|
|
+ if($obj){
|
|
|
+ $args->getEntity()->setTrafficProfile($obj);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public function assignTConProfile(LifecycleEventArgs $args, $eventName = DoctrineEvents::PRE_PERSIST)
|
|
|
+ public function assignTConProfile(LifecycleEventArgs $args, $eventName = DoctrineEvents::PRE_PERSIST){
|
|
|
+ $obj = $args->getEntityManager()->getRepository("FTTHBundle:TContProfile")->findOneBy( array("used_by_default" => true));
|
|
|
+ if($obj){
|
|
|
+ $args->getEntity()->setTcontprofile($obj);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public function assignVLanId(LifecycleEventArgs $args, $eventName = DoctrineEvents::PRE_PERSIST)
|
|
|
+ public function assignVLanId(LifecycleEventArgs $args, $eventName = DoctrineEvents::PRE_PERSIST){
|
|
|
+ $obj = $args->getEntityManager()->getRepository("FTTHBundle:VLanID")->findOneBy( array("used_by_default" => true));
|
|
|
+ if($obj){
|
|
|
+ $args->getEntity()->setVlan($obj);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|