|
@@ -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;
|
|
@@ -16,20 +17,25 @@ use MapBundle\Entity\Interfaces\LocationInterface;
|
|
|
use MapBundle\Entity\Traits\LocationTrait;
|
|
|
use WorkflowBundle\Entity\Interfaces\WorkflowInterface;
|
|
|
use WorkflowBundle\Entity\Traits\WorkflowTrait;
|
|
|
+use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity as SoftDeleteable;
|
|
|
+use Gedmo\Mapping\Annotation as Gedmo;
|
|
|
+use Base\AdminBundle\Interfaces\SoftDeleteInterface;
|
|
|
|
|
|
/**
|
|
|
* @ORM\Entity
|
|
|
* @UniqueEntity("ip")
|
|
|
+ * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true)
|
|
|
*
|
|
|
* @ValidatorAssert\Device
|
|
|
*/
|
|
|
-class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface, WorkflowInterface
|
|
|
+class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface, WorkflowInterface, PreRemoveInterface, SoftDeleteInterface
|
|
|
{
|
|
|
|
|
|
use ExtraDataTrait;
|
|
|
use TenancyIdTrait;
|
|
|
use LocationTrait;
|
|
|
use WorkflowTrait;
|
|
|
+ use SoftDeleteable;
|
|
|
|
|
|
/**
|
|
|
* @var bigint $id
|
|
@@ -93,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)
|
|
|
*/
|
|
@@ -289,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
|
|
|
*/
|
|
@@ -488,5 +533,30 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
|
|
|
{
|
|
|
return $this->libraryVersion;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function getSoftDeleteCriteria()
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
|
|
|
}
|