|
@@ -2,11 +2,7 @@
|
|
|
|
|
|
namespace CablemodemBundle\Entity;
|
|
|
|
|
|
-use Doctrine\ORM\Mapping as ORM;
|
|
|
-use Gedmo\Mapping\Annotation as Gedmo;
|
|
|
-use JMS\Serializer\Annotation as JMS;
|
|
|
-use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
|
-use Symfony\Component\Validator\Constraints as Assert;
|
|
|
+use Base\AdminBundle\Interfaces\SoftDeleteInterface;
|
|
|
use Base\AdminBundle\Traits\TenancyIdTrait;
|
|
|
use Base\AdminBundle\Traits\TenancyIdTraitInterface;
|
|
|
use DeviceBundle\Interfaces\DeviceInterface;
|
|
@@ -16,10 +12,15 @@ use MapBundle\Entity\Interfaces\LocationInterface;
|
|
|
use MapBundle\Entity\Traits\LocationTrait;
|
|
|
use WorkflowBundle\Entity\Interfaces\WorkflowInterface;
|
|
|
use WorkflowBundle\Entity\Traits\WorkflowTrait;
|
|
|
-use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity as SoftDeleteable;
|
|
|
-use Base\AdminBundle\Interfaces\SoftDeleteInterface;
|
|
|
+use Doctrine\ORM\Mapping as ORM;
|
|
|
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
|
|
|
+use Gedmo\Mapping\Annotation as Gedmo;
|
|
|
+use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity as SoftDeleteable;
|
|
|
+use JMS\Serializer\Annotation as JMS;
|
|
|
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
|
+use Symfony\Component\Validator\Constraints as Assert;
|
|
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|
|
+use Symfony\Component\Yaml\Yaml;
|
|
|
|
|
|
/**
|
|
|
* @ORM\Entity(repositoryClass="CablemodemBundle\Repository\CablemodemRepository")
|
|
@@ -86,6 +87,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
/**
|
|
|
* @ORM\ManyToOne(targetEntity="Node", fetch="EXTRA_LAZY", inversedBy="cablemodems")
|
|
|
* @ORM\JoinColumn(name="node_id", referencedColumnName="id", onDelete="SET NULL")
|
|
|
+ *
|
|
|
* @JMS\MaxDepth(1)
|
|
|
*/
|
|
|
protected $node;
|
|
@@ -93,6 +95,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
/**
|
|
|
* @ORM\ManyToOne(targetEntity="Profile", fetch="EXTRA_LAZY", inversedBy="cablemodems")
|
|
|
* @ORM\JoinColumn(name="profile_id", referencedColumnName="id", onDelete="SET NULL")
|
|
|
+ *
|
|
|
* @JMS\MaxDepth(1)
|
|
|
*
|
|
|
* @Assert\NotNull
|
|
@@ -548,6 +551,33 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function getDocsis_key()
|
|
|
+ {
|
|
|
+ $docsis_key = '';
|
|
|
+ if ($this->tenancyId) {
|
|
|
+ global $kernel;
|
|
|
+ $dir = $kernel->getProjectDir();
|
|
|
+ $filename = "{$dir}/app/config/tenencia/cablemodem_{$this->tenancyId}.yml";
|
|
|
+ if (file_exists($filename)) {
|
|
|
+ $values = Yaml::parse(file_get_contents($filename));
|
|
|
+ if (isset($values['docsis_key'])) {
|
|
|
+ $docsis_key = $values['docsis_key'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($docsis_key == '' && $this->profile) {
|
|
|
+ $docsis_key = $this->profile->getDocsis_key();
|
|
|
+ }
|
|
|
+ if ($docsis_key == '' || $docsis_key == null) {
|
|
|
+ $docsis_key = 'cmts-default';
|
|
|
+ }
|
|
|
+
|
|
|
+ return $docsis_key;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @ORM\PreUpdate()
|
|
|
* @ORM\PreUpdate()
|