Explorar el Código

Merged in FD3-688 (pull request #108)

FD3-688 softDelete en NAS
Guillermo Espinoza hace 6 años
padre
commit
fd6250465e
Se han modificado 1 ficheros con 24 adiciones y 4 borrados
  1. 24 4
      src/RadiusBundle/Entity/NAS.php

+ 24 - 4
src/RadiusBundle/Entity/NAS.php

@@ -2,12 +2,15 @@
 
 namespace RadiusBundle\Entity;
 
+use Base\AdminBundle\Interfaces\SoftDeleteInterface;
 use Base\AdminBundle\Traits\TenancyIdTrait;
 use Base\AdminBundle\Traits\TenancyIdTraitInterface;
 use Doctrine\ORM\Mapping as ORM;
 use DeviceBundle\Interfaces\DeviceInterface;
 use DeviceBundle\Validator\Constraints as ValidatorAssert;
 use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
+use Gedmo\Mapping\Annotation as Gedmo;
+use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity as SoftDeleteable;
 use MapBundle\Entity\Interfaces\LocationInterface;
 use MapBundle\Entity\Traits\LocationTrait;
 use Symfony\Component\Validator\Constraints as Assert;
@@ -20,14 +23,17 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  *
  * @UniqueEntity(fields={"host", "tenancyId"}, message="errors.duplicate_key")
  *
+ * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true)
+ *
  * @ValidatorAssert\Device
  */
-class NAS implements TenancyIdTraitInterface, DeviceInterface, LocationInterface
+class NAS implements TenancyIdTraitInterface, DeviceInterface, LocationInterface, SoftDeleteInterface
 {
 
     use ExtraDataTrait;
     use TenancyIdTrait;
     use LocationTrait;
+    use SoftDeleteable;
 
     /**
      * @var int
@@ -268,8 +274,13 @@ class NAS implements TenancyIdTraitInterface, DeviceInterface, LocationInterface
         $deviceData['ip'] = $this->host;
         $deviceData['tenancy'] = $this->tenancyId;
 
-        $deviceExtraData = array('snmpCommunity' => $this->snmpComunity, 'snmpVersion' => $this->snmpVersion, 'radiusPassword' => $this->radiusPassword,
-            'acctEnabled' => $this->acctEnabled, 'description' => $this->description);
+        $deviceExtraData = array(
+            'snmpCommunity' => $this->snmpComunity, 
+            'snmpVersion' => $this->snmpVersion, 
+            'radiusPassword' => $this->radiusPassword,
+            'acctEnabled' => $this->acctEnabled, 
+            'description' => $this->description
+        );
 
         if ($this->model) {
             $model = $this->getModel();
@@ -280,11 +291,20 @@ class NAS implements TenancyIdTraitInterface, DeviceInterface, LocationInterface
             $deviceExtraData['library'] = null;
         }
 
-
         $deviceData['extraData'] = json_encode($deviceExtraData);
 
         return $deviceData;
 
     }
+    
+    /**
+     * @return array
+     */
+    public function getSoftDeleteCriteria()
+    {
+        return [
+            'host' => $this->host,
+        ];
+    }
 
 }