downstream = $this->getDefault('downstream'); $this->upstream = $this->getDefault('upstream'); $this->template = $this->getDefault('template'); $this->cablemodems = new \Doctrine\Common\Collections\ArrayCollection(); } /** * @return string */ public function __toString() { return (string)$this->name; } /** * @return int */ public function getId() { return $this->id; } /** * @return string */ public function getName() { return $this->name; } /** * @return bigint */ public function getDownstream() { return $this->downstream ? $this->downstream : $this->getDefault('downstream'); } /** * @return bigint */ public function getUpstream() { return $this->upstream ? $this->upstream : $this->getDefault('upstream'); } /** * @return bigint */ public function getFiltroUpload() { return $this->filtroUpload; } /** * @return bigint */ public function getFiltroDownload() { return $this->filtroDownload; } /** * @return bigint */ public function getMaxCpe() { return $this->maxCpe ? $this->maxCpe : $this->getDefault('max_cpe'); } /** * @param string $name * * @return $this */ public function setName($name) { $this->name = $name; return $this; } /** * @param bigint $downstream * * @return $this */ public function setDownstream($downstream) { if(is_null($downstream)) { $this->downstream = $this->getDefault('downstream'); } else { $this->downstream = $downstream; } return $this; } /** * @param bigint $upstream * * @return $this */ public function setUpstream($upstream) { if(is_null($upstream)) { $this->upstream = $this->getDefault('upstream'); } else { $this->upstream = $upstream; } return $this; } /** * @param bigint $filtroUpload * * @return $this */ public function setFiltroUpload($filtroUpload) { $this->filtroUpload = $filtroUpload; return $this; } /** * @param bigint $filtroDownload * * @return $this */ public function setFiltroDownload($filtroDownload) { $this->filtroDownload = $filtroDownload; return $this; } /** * @param bigint $maxCpe * * @return $this */ public function setMaxCpe($maxCpe) { $this->maxCpe = $maxCpe; return $this; } /** * @return string */ public function getSipDevProxyServer() { return $this->getData('sipDevProxyServer') ? $this->getData('sipDevProxyServer') : $this->getDefault('sipDevProxyServer'); } /** * @return string */ public function getServerVoIP_IP() { return $this->getData('ServerVoIP_IP') ? $this->getData('ServerVoIP_IP') : $this->getDefault('ServerVoIP_IP'); } /** * @return string */ public function getSipDevRegistrar() { return $this->getData('sipDevRegistrar') ? $this->getData('sipDevRegistrar') : $this->getDefault('sipDevRegistrar'); } /** * @param string $name * * @return mixed */ public function getDefault($name = null) { global $kernel; $dir = $kernel->getProjectDir(); $values = Yaml::parse(file_get_contents("{$dir}/app/config/profile.yml")); $value = null; if (!is_null($name) && isset($values[$name])) { $value = $values[$name]; } return $value; } /** * @return string */ public function getTemplate() { return $this->template; } /** * @param string $template * * @return Profile */ public function setTemplate($template) { $this->template = $template; return $this; } /** * @param Cablemodem $cablemodem * @return Profile */ public function addCablemodem(Cablemodem $cablemodem) { $this->cablemodems[] = $cablemodem; return $this; } /** * @param Cablemodem $cablemodem * @return Profile */ public function removeCablemodem(Cablemodem $cablemodem) { $this->cablemodems->removeElement($cablemodem); return $this; } /** * @return Doctrine\Common\Collections\Collection */ public function getCablemodems() { return $this->cablemodems; } /** * @return array */ public function getEntitiesBlockRemove() { $entities = []; if ($this->cablemodems->count() != 0) { $entities['cablemodems'] = $this->cablemodems; } return $entities; } /** * @ORM\PreRemove */ public function preRemove(LifecycleEventArgs $event) { $em = $event->getEntityManager(); $entity = $event->getEntity(); if (count($entity->getCablemodems()) > 0) { $error = "This profile has connected cablemodems, so it can't be removed."; throw new ModelManagerException($error); } } }