|
@@ -18,6 +18,7 @@ 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\HasLifecycleCallbacks;
|
|
|
|
|
|
/**
|
|
|
* @ORM\Entity
|
|
@@ -29,6 +30,7 @@ use Base\AdminBundle\Interfaces\SoftDeleteInterface;
|
|
|
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true)
|
|
|
*
|
|
|
* @ValidatorAssert\Device
|
|
|
+ * @HasLifecycleCallbacks
|
|
|
*/
|
|
|
class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationInterface, WorkflowInterface, SoftDeleteInterface
|
|
|
{
|
|
@@ -64,8 +66,8 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
*
|
|
|
* @Gedmo\Versioned
|
|
|
*
|
|
|
- * @Assert\Regex(pattern="/^[a-z0-9]+$/")
|
|
|
- * @Assert\Length(min=12, max=12)
|
|
|
+ * @Assert\Regex(pattern="/([a-fA-F0-9]{2}[:]*){6}/")
|
|
|
+ * @Assert\Length(min=12, max=17)
|
|
|
* @Assert\NotBlank()
|
|
|
* @Assert\NotNull
|
|
|
*/
|
|
@@ -97,7 +99,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
/**
|
|
|
* @ORM\ManyToOne(targetEntity="CablemodemModel", fetch="EXTRA_LAZY")
|
|
|
* @ORM\JoinColumn(onDelete="SET NULL")
|
|
|
- *
|
|
|
+ *
|
|
|
* @JMS\MaxDepth(1)
|
|
|
*/
|
|
|
protected $model;
|
|
@@ -154,26 +156,26 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
* )
|
|
|
*/
|
|
|
protected $voip = null;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @ORM\Column(type="string", nullable=true)
|
|
|
*/
|
|
|
protected $fixedIP;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @ORM\Column(type="string", nullable=true)
|
|
|
*
|
|
|
* @Assert\Ip()
|
|
|
*/
|
|
|
protected $cpeFixedIP;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @ORM\Column(type="string", nullable=true)
|
|
|
*
|
|
|
* @Assert\Ip()
|
|
|
*/
|
|
|
protected $mtaFixedIP;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @ORM\Column(type="text", nullable=true)
|
|
|
*
|
|
@@ -187,7 +189,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
*/
|
|
|
public function __toString()
|
|
|
{
|
|
|
- return (string) ($this->mac ?: $this->activationCode);
|
|
|
+ return (string)($this->mac ?: $this->activationCode);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -415,7 +417,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
{
|
|
|
global $kernel;
|
|
|
$options = [
|
|
|
- 'filename' => $this->mac . '.bin',
|
|
|
+ 'filename' => $this->mac . '.bin',
|
|
|
];
|
|
|
$container = $kernel->getContainer();
|
|
|
if ($this->mtaEnabled && $container->hasParameter('dhcp_server_ip')) {
|
|
@@ -441,17 +443,17 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
*/
|
|
|
public function setVoip($voip)
|
|
|
{
|
|
|
- if(is_null($voip)) {
|
|
|
+ if (is_null($voip)) {
|
|
|
$this->voip = $voip;
|
|
|
-
|
|
|
+
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
$this->voip = array_values($voip);
|
|
|
-
|
|
|
+
|
|
|
return $this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @param string $index
|
|
|
*
|
|
@@ -459,11 +461,11 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
*/
|
|
|
public function getVoipData($index)
|
|
|
{
|
|
|
- if(is_null($this->voip)) return null;
|
|
|
+ if (is_null($this->voip)) return null;
|
|
|
|
|
|
- if(isset($this->voip[$index])) return $this->voip[$index];
|
|
|
+ if (isset($this->voip[$index])) return $this->voip[$index];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @return string
|
|
|
*/
|
|
@@ -471,7 +473,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
{
|
|
|
return $this->fixedIP;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @param string $fixedIP
|
|
|
*
|
|
@@ -480,10 +482,10 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
public function setFixedIP($fixedIP)
|
|
|
{
|
|
|
$this->fixedIP = $fixedIP;
|
|
|
-
|
|
|
+
|
|
|
return $this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @return string
|
|
|
*/
|
|
@@ -491,7 +493,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
{
|
|
|
return $this->cpeFixedIP;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @param string $cpeFixedIP
|
|
|
*
|
|
@@ -500,10 +502,10 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
public function setCpeFixedIP($cpeFixedIP)
|
|
|
{
|
|
|
$this->cpeFixedIP = $cpeFixedIP;
|
|
|
-
|
|
|
+
|
|
|
return $this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @return string
|
|
|
*/
|
|
@@ -511,7 +513,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
{
|
|
|
return $this->mtaFixedIP;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @param string $mtaFixedIP
|
|
|
*
|
|
@@ -520,10 +522,10 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
public function setMtaFixedIP($mtaFixedIP)
|
|
|
{
|
|
|
$this->mtaFixedIP = $mtaFixedIP;
|
|
|
-
|
|
|
+
|
|
|
return $this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @return string
|
|
|
*/
|
|
@@ -531,7 +533,7 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
{
|
|
|
return $this->comments;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @param string $comments
|
|
|
*
|
|
@@ -540,8 +542,17 @@ class Cablemodem implements DeviceInterface, TenancyIdTraitInterface, LocationIn
|
|
|
public function setComments($comments)
|
|
|
{
|
|
|
$this->comments = $comments;
|
|
|
-
|
|
|
+
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @ORM\PreUpdate()
|
|
|
+ * @ORM\PreUpdate()
|
|
|
+ */
|
|
|
+ public function prePersist()
|
|
|
+ {
|
|
|
+ $this->setMac(str_replace(":", "", $this->getMac()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|