|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace FTTHBundle\Entity;
|
|
|
|
|
|
+use Base\AdminBundle\Interfaces\PreRemoveInterface;
|
|
|
use Base\AdminBundle\Traits\TenancyIdTrait;
|
|
|
use Base\AdminBundle\Traits\TenancyIdTraitInterface;
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
@@ -27,7 +28,7 @@ use Base\AdminBundle\Interfaces\SoftDeleteInterface;
|
|
|
*
|
|
|
* @ValidatorAssert\Device
|
|
|
*/
|
|
|
-class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface, WorkflowInterface, SoftDeleteInterface
|
|
|
+class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface, WorkflowInterface, PreRemoveInterface, SoftDeleteInterface
|
|
|
{
|
|
|
|
|
|
use ExtraDataTrait;
|
|
@@ -98,12 +99,19 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
|
|
|
protected $model;
|
|
|
|
|
|
/**
|
|
|
- * @ORM\OneToMany(targetEntity="ONU", mappedBy="olt", fetch="EXTRA_LAZY")
|
|
|
+ * @ORM\OneToMany(targetEntity="ONU", mappedBy="olt", fetch="EXTRA_LAZY", cascade={"remove"})
|
|
|
*
|
|
|
* @JMS\MaxDepth(2)
|
|
|
*/
|
|
|
protected $onus;
|
|
|
|
|
|
+ /**
|
|
|
+ * @ORM\OneToMany(targetEntity="NAP", mappedBy="olt", fetch="EXTRA_LAZY", cascade={"remove"})
|
|
|
+ *
|
|
|
+ * @JMS\MaxDepth(2)
|
|
|
+ */
|
|
|
+ protected $naps;
|
|
|
+
|
|
|
/**
|
|
|
* @ORM\Column(type="string", nullable=true)
|
|
|
*/
|
|
@@ -294,6 +302,38 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
|
|
|
return $this->onus;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param NAP $nap
|
|
|
+ *
|
|
|
+ * @return OLT
|
|
|
+ */
|
|
|
+ public function addNap(NAP $nap)
|
|
|
+ {
|
|
|
+ $this->naps[] = $nap;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param NAP $nap
|
|
|
+ *
|
|
|
+ * @return OLT
|
|
|
+ */
|
|
|
+ public function removeNap(NAP $nap)
|
|
|
+ {
|
|
|
+ $this->naps->removeElement($nap);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Doctrine\Common\Collections\Collection
|
|
|
+ */
|
|
|
+ public function getNaps()
|
|
|
+ {
|
|
|
+ return $this->naps;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @return OLTModel
|
|
|
*/
|
|
@@ -502,4 +542,21 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
|
|
|
return array('ip' => $this->ip);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getEntitiesForRemove()
|
|
|
+ {
|
|
|
+ $entities = [];
|
|
|
+ if ($this->onus->count() != 0) {
|
|
|
+ $entities['onus'] = $this->onus;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($this->naps->count() != 0) {
|
|
|
+ $entities['naps'] = $this->naps;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $entities;
|
|
|
+ }
|
|
|
+
|
|
|
}
|