|
@@ -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);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|