|
@@ -2,19 +2,21 @@
|
|
|
|
|
|
namespace CablemodemBundle\Entity;
|
|
namespace CablemodemBundle\Entity;
|
|
|
|
|
|
-use Base\AdminBundle\Interfaces\PreRemoveInterface;
|
|
|
|
|
|
+use Base\AdminBundle\Traits\TenancyIdTrait;
|
|
|
|
+use Base\AdminBundle\Traits\TenancyIdTraitInterface;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use JMS\Serializer\Annotation as JMS;
|
|
use JMS\Serializer\Annotation as JMS;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
-use Base\AdminBundle\Traits\TenancyIdTrait;
|
|
|
|
-use Base\AdminBundle\Traits\TenancyIdTraitInterface;
|
|
|
|
|
|
+use Base\AdminBundle\Interfaces\PreRemoveInterface;
|
|
|
|
+use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
|
|
|
|
+use Sonata\AdminBundle\Exception\ModelManagerException;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Entity
|
|
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"name","tenancy_id"})})
|
|
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"name","tenancy_id"})})
|
|
- *
|
|
|
|
|
|
+ * @ORM\HasLifecycleCallbacks
|
|
* @UniqueEntity(fields={"tenancyId","name"})
|
|
* @UniqueEntity(fields={"tenancyId","name"})
|
|
*/
|
|
*/
|
|
class Node implements TenancyIdTraitInterface, PreRemoveInterface
|
|
class Node implements TenancyIdTraitInterface, PreRemoveInterface
|
|
@@ -51,6 +53,11 @@ class Node implements TenancyIdTraitInterface, PreRemoveInterface
|
|
*/
|
|
*/
|
|
protected $childs;
|
|
protected $childs;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @ORM\OneToMany(targetEntity="Cablemodem", mappedBy="node", fetch="EXTRA_LAZY")
|
|
|
|
+ */
|
|
|
|
+ protected $cablemodems;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* Constructor
|
|
* Constructor
|
|
@@ -58,6 +65,7 @@ class Node implements TenancyIdTraitInterface, PreRemoveInterface
|
|
public function __construct()
|
|
public function __construct()
|
|
{
|
|
{
|
|
$this->childs = new ArrayCollection;
|
|
$this->childs = new ArrayCollection;
|
|
|
|
+ $this->cablemodems = new ArrayCollection;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -157,5 +165,35 @@ class Node implements TenancyIdTraitInterface, PreRemoveInterface
|
|
|
|
|
|
return $entities;
|
|
return $entities;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param Cablemodem $cablemodem
|
|
|
|
+ * @return Node
|
|
|
|
+ */
|
|
|
|
+ public function addCablemodem(Cablemodem $cablemodem)
|
|
|
|
+ {
|
|
|
|
+ $this->cablemodems[] = $cablemodem;
|
|
|
|
+
|
|
|
|
+ return $this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param Cablemodem $cablemodem
|
|
|
|
+ * @return Node
|
|
|
|
+ */
|
|
|
|
+ public function removeCablemodem(Cablemodem $cablemodem)
|
|
|
|
+ {
|
|
|
|
+ $this->cablemodems->removeElement($cablemodem);
|
|
|
|
+
|
|
|
|
+ return $this;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return Doctrine\Common\Collections\Collection
|
|
|
|
+ */
|
|
|
|
+ public function getCablemodems()
|
|
|
|
+ {
|
|
|
|
+ return $this->cablemodems;
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|