|
@@ -5,6 +5,11 @@ namespace FTTHBundle\EventListener;
|
|
|
use Doctrine\Common\EventSubscriber;
|
|
|
use Doctrine\ORM\Event\LifecycleEventArgs;
|
|
|
use FTTHBundle\Entity\ONU;
|
|
|
+use FTTHBundle\Entity\ONUProfile;
|
|
|
+use FTTHBundle\Entity\VLanID;
|
|
|
+use FTTHBundle\Entity\VLanProfile;
|
|
|
+use FTTHBundle\Entity\TContProfile;
|
|
|
+use FTTHBundle\Entity\TrafficProfile;
|
|
|
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
|
|
use Symfony\Component\Translation\TranslatorInterface;
|
|
|
use WorkflowBundle\Utils\DoctrineEvents;
|
|
@@ -125,9 +130,21 @@ class ONUSubscriber implements EventSubscriber
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!$entity->getTrafficProfile()) $this->assignTrafficProfile($args);
|
|
|
- if (!$entity->getTcontprofile()) $this->assignTConProfile($args);
|
|
|
- if (!$entity->getVlan()) $this->assignVLanId($args);
|
|
|
+ if (!$entity->getTrafficProfile()) {
|
|
|
+ $this->assignTrafficProfile($args);
|
|
|
+ }
|
|
|
+ if (!$entity->getVlanProfile()) {
|
|
|
+ $this->assignVlanProfile($args);
|
|
|
+ }
|
|
|
+ if (!$entity->getONUProfile()) {
|
|
|
+ $this->assignONUProfile($args);
|
|
|
+ }
|
|
|
+ if (!$entity->getTcontprofile()) {
|
|
|
+ $this->assignTConProfile($args);
|
|
|
+ }
|
|
|
+ if (!$entity->getVlan()) {
|
|
|
+ $this->assignVLanId($args);
|
|
|
+ }
|
|
|
|
|
|
if ($eventName == DoctrineEvents::PRE_UPDATE) {
|
|
|
$uow = $this->em->getUnitOfWork();
|
|
@@ -181,9 +198,9 @@ class ONUSubscriber implements EventSubscriber
|
|
|
public function assignTrafficProfile(LifecycleEventArgs $args)
|
|
|
{
|
|
|
$obj = $args->getEntityManager()
|
|
|
- ->getRepository("FTTHBundle:TrafficProfile")
|
|
|
+ ->getRepository(TrafficProfile::class)
|
|
|
->findOneBy(array(
|
|
|
- "usedByDefault" => true
|
|
|
+ "usedByDefault" => true,
|
|
|
));
|
|
|
if ($obj) {
|
|
|
$args->getEntity()->setTrafficProfileOut($obj);
|
|
@@ -191,6 +208,38 @@ class ONUSubscriber implements EventSubscriber
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param LifecycleEventArgs $args
|
|
|
+ * @param string $eventName
|
|
|
+ */
|
|
|
+ public function assignVlanProfile(LifecycleEventArgs $args)
|
|
|
+ {
|
|
|
+ $obj = $args->getEntityManager()
|
|
|
+ ->getRepository(VLanProfile::class)
|
|
|
+ ->findOneBy(array(
|
|
|
+ "usedByDefault" => true,
|
|
|
+ ));
|
|
|
+ if ($obj) {
|
|
|
+ $args->getEntity()->setVlanProfile($obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param LifecycleEventArgs $args
|
|
|
+ * @param string $eventName
|
|
|
+ */
|
|
|
+ public function assignONUProfile(LifecycleEventArgs $args)
|
|
|
+ {
|
|
|
+ $obj = $args->getEntityManager()
|
|
|
+ ->getRepository(ONUProfile::class)
|
|
|
+ ->findOneBy(array(
|
|
|
+ "usedByDefault" => true,
|
|
|
+ ));
|
|
|
+ if ($obj) {
|
|
|
+ $args->getEntity()->setONUProfile($obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param LifecycleEventArgs $args
|
|
|
* @param string $eventName
|
|
@@ -198,9 +247,9 @@ class ONUSubscriber implements EventSubscriber
|
|
|
public function assignTConProfile(LifecycleEventArgs $args)
|
|
|
{
|
|
|
$obj = $args->getEntityManager()
|
|
|
- ->getRepository("FTTHBundle:TContProfile")
|
|
|
+ ->getRepository(TContProfile::class)
|
|
|
->findOneBy(array(
|
|
|
- "usedByDefault" => true
|
|
|
+ "usedByDefault" => true,
|
|
|
));
|
|
|
if ($obj) {
|
|
|
$args->getEntity()->setTcontprofile($obj);
|
|
@@ -214,9 +263,9 @@ class ONUSubscriber implements EventSubscriber
|
|
|
public function assignVLanId(LifecycleEventArgs $args)
|
|
|
{
|
|
|
$obj = $args->getEntityManager()
|
|
|
- ->getRepository("FTTHBundle:VLanID")
|
|
|
+ ->getRepository(VLanID::class)
|
|
|
->findOneBy(array(
|
|
|
- "usedByDefault" => true
|
|
|
+ "usedByDefault" => true,
|
|
|
));
|
|
|
if ($obj) {
|
|
|
$args->getEntity()->setVlan($obj);
|