Browse Source

Cambio del RESTController a abstract

gabriel 7 years ago
parent
commit
500ba81b99
1 changed files with 7 additions and 4 deletions
  1. 7 4
      Controller/RESTController.php

+ 7 - 4
Controller/RESTController.php

@@ -16,9 +16,12 @@ use Symfony\Component\HttpFoundation\Response;
 
 use Voryx\RESTGeneratorBundle\Controller\VoryxController;
 
-class RESTController extends VoryxController
+abstract class RESTController extends VoryxController
 {
-    var $repository = 'ClientBundle:Client';
+    /**
+     * @return string Retorna el nombre de la Entity de trabajo.
+     */
+    abstract public function getRepository();
 
     /**
      * Get all entities.
@@ -73,7 +76,7 @@ class RESTController extends VoryxController
                     $criteria->orderBy($orderBy);
                 }
 
-                $repo = $em->getRepository($this->repository);
+                $repo = $em->getRepository($this->getRepository());
                 $entities = $repo->matching($criteria)->toArray();
 
                 if ($entities) {
@@ -89,7 +92,7 @@ class RESTController extends VoryxController
                 $offset = $paramFetcher->get('offset');
                 $limit = $paramFetcher->get('limit');
                 $order_by = $paramFetcher->get('order_by');
-                $entities = $em->getRepository($this->repository)->findBy($filters, $order_by, $limit, $offset);
+                $entities = $em->getRepository($this->getRepository())->findBy($filters, $order_by, $limit, $offset);
 
                 if ($entities) {
                     return $entities;