123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <?php
- namespace IPv4Bundle\Entity;
- use Base\AdminBundle\Interfaces\PreRemoveInterface;
- use Base\AdminBundle\Traits\TenancyIdTrait;
- use Base\AdminBundle\Traits\TenancyIdTraitInterface;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Validator\Constraints as Assert;
- use Symfony\Component\Validator\ExecutionContext;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- /**
- * @ORM\Entity
- *
- * @UniqueEntity("name")
- * @UniqueEntity("opcode")
- */
- class NetGroup implements TenancyIdTraitInterface, PreRemoveInterface
- {
- use TenancyIdTrait;
- /**
- * @var bigint $id
- *
- * @ORM\Column(name="id", type="bigint", nullable=false)
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="IDENTITY")
- */
- protected $id;
- /**
- * @var string $name
- *
- * @ORM\Column(type="string", length=100, unique=true)
- *
- * @Assert\NotBlank
- */
- protected $name;
- /**
- * @var string $opcode
- *
- * @ORM\Column(type="integer", unique=true)
- *
- * @Assert\NotBlank
- */
- protected $opcode;
- /**
- * @ORM\OneToMany(targetEntity="SubNet", mappedBy="netGroup")
- */
- protected $subNets;
- /**
- * @return string
- */
- public function __toString()
- {
- return strval($this->name);
- }
- /**
- * @return bigint
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param string $name
- *
- * @return NetGroup
- */
- public function setName($name)
- {
- $this->name = $name;
- return $this;
- }
- /**
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * @param string $opcode
- *
- * @return NetGroup
- */
- public function setOpcode($opcode)
- {
- $this->opcode = $opcode;
- return $this;
- }
- /**
- * @return string
- */
- public function getOpcode()
- {
- return $this->opcode;
- }
- /**
- * @return array
- */
- public function getEntitiesForRemove()
- {
- $entities = [];
- if ($this->subNets->count() != 0) {
- $entities['subNets'] = $this->subNets;
- }
- return $entities;
- }
- }
|