|
@@ -15,13 +15,17 @@ class ONUType extends AbstractType
|
|
|
{
|
|
|
|
|
|
protected $webservice = null;
|
|
|
- public function setWebService($ws){
|
|
|
- $this->webservice = $ws;
|
|
|
+
|
|
|
+ public function setWebService($ws)
|
|
|
+ {
|
|
|
+ $this->webservice = $ws;
|
|
|
}
|
|
|
|
|
|
protected $em = null;
|
|
|
- public function setEntityManager($em){
|
|
|
- $this->em = $em;
|
|
|
+
|
|
|
+ public function setEntityManager($em)
|
|
|
+ {
|
|
|
+ $this->em = $em;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -30,65 +34,64 @@ class ONUType extends AbstractType
|
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
|
{
|
|
|
$builder->add('ip')
|
|
|
- ->add('mac')
|
|
|
- ->add('serialNumber')
|
|
|
- ->add('profile')
|
|
|
- ->add('model')
|
|
|
- ->add('nap')
|
|
|
- ->add('ponSerialNumber')
|
|
|
- ->add('clientId')
|
|
|
- ->add('tenancyId')
|
|
|
- ;
|
|
|
-
|
|
|
- $builder->addEventListener(
|
|
|
+ ->add('mac')
|
|
|
+ ->add('serialNumber')
|
|
|
+ ->add('profile')
|
|
|
+ ->add('model')
|
|
|
+ ->add('nap')
|
|
|
+ ->add('ponSerialNumber')
|
|
|
+ ->add('clientId')
|
|
|
+ ->add('tenancyId');
|
|
|
+
|
|
|
+ $builder->addEventListener(
|
|
|
FormEvents::PRE_SUBMIT,
|
|
|
function (FormEvent $event) {
|
|
|
$form = $event->getForm();
|
|
|
|
|
|
$data = $event->getData();
|
|
|
|
|
|
- $clientID = $data['clientId'];
|
|
|
-
|
|
|
- if(is_array($clientID) and $this->webservice){
|
|
|
- $clientID["disableTenancy"] = 1;
|
|
|
- $remote_data = $this->webservice->getData("client", $clientID);
|
|
|
- if(count($remote_data) === 1){
|
|
|
- $data["clientId"] = $remote_data[0]["id"];
|
|
|
- }else{
|
|
|
- unset($data["clientId"]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(isset($data["profile"]) and is_array($data["profile"]) and $this->em){
|
|
|
- $profile = $this->em->getRepository("FTTHBundle\Entity\Profile")->findOneBy($data["profile"]);
|
|
|
- unset($data["profile"]);
|
|
|
- if($profile){
|
|
|
- $data["profile"] = $profile->getId();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(isset($data["model"]) and is_array($data["model"]) and $this->em){
|
|
|
- $model = $this->em->getRepository("FTTHBundle\Entity\ONUModel")->findOneBy($data["model"]);
|
|
|
- unset($data["model"]);
|
|
|
- if($model){
|
|
|
- $data["model"] = $model->getId();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(isset($data["nap"]) and is_array($data["nap"]) and $this->em){
|
|
|
- $nap= $this->em->getRepository("FTTHBundle\Entity\NAP")->findOneBy($data["nap"]);
|
|
|
- unset($data["nap"]);
|
|
|
- if($nap){
|
|
|
- $data["nap"] = $nap->getId();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $event->setData($data);
|
|
|
+ $clientID = $data['clientId'];
|
|
|
+
|
|
|
+ if (is_array($clientID) and $this->webservice) {
|
|
|
+ $clientID["disableTenancy"] = 1;
|
|
|
+ $remote_data = $this->webservice->getData("client", $clientID);
|
|
|
+ if (count($remote_data) === 1) {
|
|
|
+ $data["clientId"] = $remote_data[0]["id"];
|
|
|
+ } else {
|
|
|
+ unset($data["clientId"]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($data["profile"]) and is_array($data["profile"]) and $this->em) {
|
|
|
+ $profile = $this->em->getRepository("FTTHBundle\Entity\Profile")->findOneBy($data["profile"]);
|
|
|
+ unset($data["profile"]);
|
|
|
+ if ($profile) {
|
|
|
+ $data["profile"] = $profile->getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($data["model"]) and is_array($data["model"]) and $this->em) {
|
|
|
+ $model = $this->em->getRepository("FTTHBundle\Entity\ONUModel")->findOneBy($data["model"]);
|
|
|
+ unset($data["model"]);
|
|
|
+ if ($model) {
|
|
|
+ $data["model"] = $model->getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($data["nap"]) and is_array($data["nap"]) and $this->em) {
|
|
|
+ $nap = $this->em->getRepository("FTTHBundle\Entity\NAP")->findOneBy($data["nap"]);
|
|
|
+ unset($data["nap"]);
|
|
|
+ if ($nap) {
|
|
|
+ $data["nap"] = $nap->getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $event->setData($data);
|
|
|
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* {@inheritdoc}
|
|
|
*/
|