|
@@ -4,7 +4,9 @@ namespace FTTHBundle\Entity;
|
|
|
|
|
|
use Base\AdminBundle\Traits\TenancyIdTrait;
|
|
|
use Base\AdminBundle\Traits\TenancyIdTraitInterface;
|
|
|
+use Doctrine\ORM\Event\PreUpdateEventArgs;
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
+use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
|
|
|
use ExtraDataBundle\Entity\Traits\ExtraDataWithParentTrait;
|
|
|
use JMS\Serializer\Annotation as JMS;
|
|
|
use MapBundle\Entity\Interfaces\LocationInterface;
|
|
@@ -15,6 +17,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|
|
/**
|
|
|
* @ORM\Table
|
|
|
* @ORM\Entity
|
|
|
+ * @HasLifecycleCallbacks
|
|
|
*/
|
|
|
class NAP implements TenancyIdTraitInterface, LocationInterface
|
|
|
{
|
|
@@ -96,7 +99,12 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
|
|
|
* @ORM\Column(type="string", length=255, nullable=true)
|
|
|
*/
|
|
|
protected $address;
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @var int
|
|
|
+ *
|
|
|
+ * @ORM\Column(type="integer")
|
|
|
+ */
|
|
|
+ protected $capacity;
|
|
|
|
|
|
/**
|
|
|
* @return string
|
|
@@ -196,9 +204,31 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
|
|
|
*/
|
|
|
public function getCapacity()
|
|
|
{
|
|
|
- return $this->getData('capacity') ? $this->getData('capacity') : self::MAX_NUMBER_ONU;
|
|
|
+
|
|
|
+ if ($this->capacity) {
|
|
|
+ $capacity = $this->capacity;
|
|
|
+ } else {
|
|
|
+ if ($this->getData('capacity')) {
|
|
|
+ $capacity = $this->getData('capacity');
|
|
|
+ } else {
|
|
|
+ $capacity = self::MAX_NUMBER_ONU;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->setCapacity($capacity);
|
|
|
+ return $capacity;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param int $capacity
|
|
|
+ * @return NAP
|
|
|
+ */
|
|
|
+ public function setCapacity($capacity)
|
|
|
+ {
|
|
|
+ $this->capacity = $capacity;
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @return OLT
|
|
|
*/
|
|
@@ -258,41 +288,43 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
- public function getlat(){
|
|
|
- // if($this->location->lat) return $this->location->lat;
|
|
|
- if($l = $this->getLocation()){
|
|
|
- $le = $l->jsonExtraData();
|
|
|
- if(isset($le["lat"])){
|
|
|
- return $le["lat"];
|
|
|
- }
|
|
|
- }
|
|
|
- return $this->lat;
|
|
|
+ public function getlat()
|
|
|
+ {
|
|
|
+ // if($this->location->lat) return $this->location->lat;
|
|
|
+ if ($l = $this->getLocation()) {
|
|
|
+ $le = $l->jsonExtraData();
|
|
|
+ if (isset($le["lat"])) {
|
|
|
+ return $le["lat"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $this->lat;
|
|
|
}
|
|
|
|
|
|
- public function getlng(){
|
|
|
- //if($this->location->lng) return $this->location->lng;
|
|
|
- if($l = $this->getLocation()){
|
|
|
- $le = $l->jsonExtraData();
|
|
|
- if(isset($le["lng"])){
|
|
|
- return $le["lng"];
|
|
|
- }
|
|
|
- }
|
|
|
- return $this->lng;
|
|
|
+ public function getlng()
|
|
|
+ {
|
|
|
+ //if($this->location->lng) return $this->location->lng;
|
|
|
+ if ($l = $this->getLocation()) {
|
|
|
+ $le = $l->jsonExtraData();
|
|
|
+ if (isset($le["lng"])) {
|
|
|
+ return $le["lng"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $this->lng;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return string
|
|
|
- */
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
public function getAddress()
|
|
|
{
|
|
|
return $this->address;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param string $address
|
|
|
- *
|
|
|
- * @return Nap
|
|
|
- */
|
|
|
+ * @param string $address
|
|
|
+ *
|
|
|
+ * @return Nap
|
|
|
+ */
|
|
|
public function setAddress($address)
|
|
|
{
|
|
|
$this->address = $address;
|
|
@@ -300,4 +332,27 @@ class NAP implements TenancyIdTraitInterface, LocationInterface
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @ORM\PrePersist()
|
|
|
+ */
|
|
|
+ public function prePersist()
|
|
|
+ {
|
|
|
+ if ($this->capacity) {
|
|
|
+ $json = json_decode($this->getExtraData(), true);
|
|
|
+ $json['capacity'] = $this->getCapacity();
|
|
|
+ $this->setExtraData(json_encode($json));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\PreUpdate()
|
|
|
+ */
|
|
|
+ public function preUpdate()
|
|
|
+ {
|
|
|
+ if ($this->capacity) {
|
|
|
+ $json = json_decode($this->getExtraData(), true);
|
|
|
+ $json['capacity'] = $this->getCapacity();
|
|
|
+ $this->setExtraData(json_encode($json));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|