Переглянути джерело

refactory ONURESTController

Guillermo Espinoza 8 роки тому
батько
коміт
89b40ae042
2 змінених файлів з 11 додано та 57 видалено
  1. 4 4
      composer.lock
  2. 7 53
      src/FTTHBundle/Controller/ONURESTController.php

+ 4 - 4
composer.lock

@@ -4,8 +4,8 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "hash": "aac44b5fdaca955ef305a59980175c9f",
-    "content-hash": "b5d8d1c586c8631e23f99cffafad96fe",
+    "hash": "d473b494d2ccfdf5e71166ef0c5d810e",
+    "content-hash": "7b318265b54fca97b4f497cbdc157b26",
     "packages": [
         {
             "name": "base-admin",
@@ -4711,7 +4711,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/Webservice.git",
-                "reference": "abbfd53c02b538306478b9abe004ec67ceeeb8e2"
+                "reference": "182ba6ba444181cbd94b210ac321c2ea808d7707"
             },
             "type": "library",
             "autoload": {
@@ -4720,7 +4720,7 @@
                 }
             },
             "description": "The Flowdat3 Webservice Rest",
-            "time": "2017-02-21 15:30:04"
+            "time": "2017-02-21 18:24:47"
         },
         {
             "name": "willdurand/jsonp-callback-validator",

+ 7 - 53
src/FTTHBundle/Controller/ONURESTController.php

@@ -4,72 +4,22 @@ namespace FTTHBundle\Controller;
 
 use FTTHBundle\Entity\ONU;
 use FTTHBundle\Form\ONUType;
-
-use FOS\RestBundle\Controller\Annotations\QueryParam;
 use FOS\RestBundle\Controller\Annotations\RouteResource;
 use FOS\RestBundle\Controller\Annotations\View;
-use FOS\RestBundle\Request\ParamFetcherInterface;
 use FOS\RestBundle\Util\Codes;
 use FOS\RestBundle\View\View as FOSView;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-use Symfony\Component\Form\Form;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
-
-use Voryx\RESTGeneratorBundle\Controller\VoryxController;
+use WebserviceBundle\Controller\RESTController;
 
 /**
  * ONU controller.
  * @RouteResource("ONU")
  */
-class ONURESTController extends VoryxController
+class ONURESTController extends RESTController
 {
-    /**
-     * Get a ONU entity
-     *
-     * @View(serializerEnableMaxDepthChecks=true)
-     *
-     * @return Response
-     *
-     */
-    public function getAction(ONU $entity)
-    {
-        return $entity;
-    }
-    /**
-     * Get all ONU entities.
-     *
-     * @View(serializerEnableMaxDepthChecks=true)
-     *
-     * @param ParamFetcherInterface $paramFetcher
-     *
-     * @return Response
-     *
-     * @QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing notes.")
-     * @QueryParam(name="limit", requirements="\d+", default="20", description="How many notes to return.")
-     * @QueryParam(name="order_by", nullable=true, array=true, description="Order by fields. Must be an array ie. &order_by[name]=ASC&order_by[description]=DESC")
-     * @QueryParam(name="filters", nullable=true, array=true, description="Filter by fields. Must be an array ie. &filters[id]=3")
-     */
-    public function cgetAction(ParamFetcherInterface $paramFetcher)
-    {
-        try {
-            $offset = $paramFetcher->get('offset');
-            $limit = $paramFetcher->get('limit');
-            $order_by = $paramFetcher->get('order_by');
-            $filters = !is_null($paramFetcher->get('filters')) ? $paramFetcher->get('filters') : array();
-
-            $em = $this->getDoctrine()->getManager();
-            $entities = $em->getRepository('FTTHBundle:ONU')->findBy($filters, $order_by, $limit, $offset);
-            if ($entities) {
-                return $entities;
-            }
+    var $repository = 'FTTHBundle:ONU';
 
-            return FOSView::create('Not Found', Codes::HTTP_NO_CONTENT);
-        } catch (\Exception $e) {
-            return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR);
-        }
-    }
     /**
      * Create a ONU entity.
      *
@@ -97,6 +47,7 @@ class ONURESTController extends VoryxController
 
         return FOSView::create(array('errors' => $form->getErrors()), Codes::HTTP_INTERNAL_SERVER_ERROR);
     }
+
     /**
      * Update a ONU entity.
      *
@@ -126,6 +77,7 @@ class ONURESTController extends VoryxController
             return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR);
         }
     }
+
     /**
      * Partial Update to a ONU entity.
      *
@@ -140,6 +92,7 @@ class ONURESTController extends VoryxController
     {
         return $this->putAction($request, $entity);
     }
+
     /**
      * Delete a ONU entity.
      *
@@ -162,4 +115,5 @@ class ONURESTController extends VoryxController
             return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR);
         }
     }
+
 }