123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?php
- namespace IPv4Bundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use JMS\Serializer\Annotation as JMS;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use IPv4Bundle\Traits\DHCPOptionTrait;
- /**
- * @ORM\Entity
- * @ORM\HasLifecycleCallbacks
- * @UniqueEntity("mac")
- */
- class Host
- {
- use DHCPOptionTrait;
- const STATE_ACTIVE = 'active';
- const STATE_SUSPENDED = 'suspended';
- /**
- * @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)
- */
- protected $mac;
- /**
- * @var string $options
- *
- * @ORM\Column(type="text", nullable=true)
- */
- protected $options;
- /**
- * @var HostType $hostType
- *
- * @ORM\ManyToOne(targetEntity="HostType", inversedBy="hosts")
- * @ORM\JoinColumn(onDelete="CASCADE")
- *
- * @JMS\MaxDepth(1)
- */
- protected $hostType;
- /**
- * @var string $state
- *
- * @ORM\Column(type="string", options={"default": "active"})
- */
- protected $state = self::STATE_ACTIVE;
- /**
- * @return string
- */
- public function __toString()
- {
- return strval($this->mac);
- }
- /**
- * @return bigint
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param string $mac
- *
- * @return Host
- */
- public function setMac($mac)
- {
- $this->mac = $mac;
- return $this;
- }
- /**
- * @return string
- */
- public function getMac()
- {
- return $this->mac;
- }
- /**
- * @param text $options
- *
- * @return Host
- */
- public function setOptions($options)
- {
- $this->options = $options;
- return $this;
- }
- /**
- * @return text
- */
- public function getOptions()
- {
- return $this->options;
- }
- /**
- * @param HostType $hostType
- *
- * @return Host
- */
- public function setHostType(HostType $hostType)
- {
- $this->hostType = $hostType;
- return $this;
- }
- /**
- * @return HostType
- */
- public function getHostType()
- {
- return $this->hostType;
- }
- /**
- * @return string
- */
- public function getState()
- {
- return $this->state;
- }
- /**
- * @param string $state
- *
- * @return Host
- */
- public function setState($state = self::STATE_ACTIVE)
- {
- $this->state = $state;
- return $this;
- }
- }
|