|
@@ -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;
|
|
@@ -23,7 +24,7 @@ use WorkflowBundle\Entity\Traits\WorkflowTrait;
|
|
|
*
|
|
|
* @ValidatorAssert\Device
|
|
|
*/
|
|
|
-class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface, WorkflowInterface
|
|
|
+class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface, WorkflowInterface, PreRemoveInterface
|
|
|
{
|
|
|
|
|
|
use ExtraDataTrait;
|
|
@@ -93,14 +94,14 @@ 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")
|
|
|
+ * @ORM\OneToMany(targetEntity="NAP", mappedBy="olt", fetch="EXTRA_LAZY", cascade={"remove"})
|
|
|
*
|
|
|
* @JMS\MaxDepth(2)
|
|
|
*/
|
|
@@ -528,4 +529,21 @@ class OLT implements DeviceInterface, TenancyIdTraitInterface, LocationInterface
|
|
|
return $this->libraryVersion;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @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;
|
|
|
+ }
|
|
|
+
|
|
|
}
|