ipPool = new ArrayCollection; } /** * @return string */ public function __toString() { return strval($this->address); } /** * @return bigint */ public function getId() { return $this->id; } /** * @param string $address * * @return SubNet */ public function setAddress($address) { $this->address = $address; return $this; } /** * @return string */ public function getAddress() { return $this->address; } /** * @param text $options * * @return SubNet */ public function setOptions($options) { $this->options = $options; return $this; } /** * @return string */ public function getOptions() { return $this->options; } /** * @param HostType $allowedHostType * * @return SubNet */ public function setAllowedHostType(HostType $allowedHostType) { $this->allowedHostType = $allowedHostType; return $this; } /** * @return HostType */ public function getAllowedHostType() { return $this->allowedHostType; } /** * @param NetGroup $netGroup * * @return SubNet */ public function setNetGroup(NetGroup $netGroup) { $this->netGroup = $netGroup; return $this; } /** * @return NetGroup */ public function getNetGroup() { return $this->netGroup; } /** * @param Pool $ipPool * * @return SubNet */ public function addIpPool(Pool $ipPool) { $ipPool->setSubNet($this); $this->ipPool[] = $ipPool; return $this; } /** * @param Pool $ipPool * * @return SubNet */ public function removeIpPool(Pool $ipPool) { $ipPool->setSubNet(null); $this->ipPool->removeElement($ipPool); return $this; } /** * @return Doctrine\Common\Collections\Collection */ public function getIpPool() { return $this->ipPool; } /** * @param Doctrine\Common\Collections\Collection $ipPool * * @return SubNet */ public function setIpPool($ipPool) { $this->ipPool = $ipPool; return $this; } /** * @return string */ public function getSubnetName() { if ($this->getAllowedHostType() && $this->getNetGroup()) { return "{$this->address} ({$this->getAllowedHostType()->getShortName()}) - {$this->getNetGroup()->getName()}"; } else { return $this->address; } } /** * @param array $status * * @return SubNet */ public function setStatus($status) { $statuses = array_values(\HostBundle\Utils\HostStatus::getConstants()); $this->status = []; foreach ($statuses as $key => $s) { if (in_array($s, $status)) { $k = array_search($s, $status); $this->status[$key] = $status[$k]; } } return $this; } /** * @return array */ public function getStatus() { return $this->status; } /** * @return string */ public function getStatusString() { return implode(',', array_values($this->status)); } /** * @param ExecutionContextInterface $context */ public function validateAddress(ExecutionContextInterface $context) { $address_pieces = explode('/', $this->address); if (!(count($address_pieces) == 2 && filter_var($address_pieces[0], FILTER_VALIDATE_IP) && (filter_var($address_pieces[1], FILTER_VALIDATE_IP) || (is_numeric($address_pieces[1]) && 0 <= $address_pieces[1] && $address_pieces[1] <= 32)))) { $context->addViolation('subnet.address.error'); } } }