|
@@ -36,7 +36,7 @@ abstract class RESTController extends VoryxController
|
|
|
{
|
|
|
return get_class(new ClientType());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Get all entities.
|
|
|
*
|
|
@@ -56,7 +56,6 @@ abstract class RESTController extends VoryxController
|
|
|
public function cgetAction(ParamFetcherInterface $paramFetcher)
|
|
|
{
|
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
-
|
|
|
$disableTenancy = false;
|
|
|
$filters = !is_null($paramFetcher->get('filters')) ? $paramFetcher->get('filters') : array();
|
|
|
if (isset($filters['tenancyId'])) {
|
|
@@ -72,28 +71,28 @@ abstract class RESTController extends VoryxController
|
|
|
$tenancyService->disableFilter();
|
|
|
unset($filters['disableTenancy']);
|
|
|
}
|
|
|
- if(isset($filters['qb-criteria'])) {
|
|
|
+ if (isset($filters['qb-criteria'])) {
|
|
|
try {
|
|
|
|
|
|
unset($filters['qb-criteria']);
|
|
|
$criteria = new \Doctrine\Common\Collections\Criteria();
|
|
|
|
|
|
- foreach($filters as $field => $value) {
|
|
|
+ foreach ($filters as $field => $value) {
|
|
|
$criteria->andWhere($criteria->expr()->contains("$field", "$value"));
|
|
|
}
|
|
|
|
|
|
- if(!is_null($paramFetcher->get('offset'))) {
|
|
|
+ if (!is_null($paramFetcher->get('offset'))) {
|
|
|
$criteria->setFirstResult($paramFetcher->get('offset'));
|
|
|
}
|
|
|
|
|
|
- if(!is_null($paramFetcher->get('limit'))) {
|
|
|
+ if (!is_null($paramFetcher->get('limit'))) {
|
|
|
$criteria->setMaxResults($paramFetcher->get('limit'));
|
|
|
}
|
|
|
|
|
|
- if($paramFetcher->get('order_by')) {
|
|
|
+ if ($paramFetcher->get('order_by')) {
|
|
|
$order_by = $paramFetcher->get('order_by');
|
|
|
$orderBy = array();
|
|
|
- foreach($order_by as $field => $order) {
|
|
|
+ foreach ($order_by as $field => $order) {
|
|
|
$orderBy[$field] = $order;
|
|
|
}
|
|
|
$criteria->orderBy($orderBy);
|
|
@@ -106,11 +105,11 @@ abstract class RESTController extends VoryxController
|
|
|
if ($entities) {
|
|
|
return $entities;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
} catch (\Exception $e) {
|
|
|
return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
} else {
|
|
|
try {
|
|
|
$offset = $paramFetcher->get('offset');
|
|
@@ -129,7 +128,7 @@ abstract class RESTController extends VoryxController
|
|
|
|
|
|
}
|
|
|
|
|
|
- return array();
|
|
|
+ return array();
|
|
|
}
|
|
|
/**
|
|
|
* @return object Retorna el nombre de la Entity de trabajo.
|
|
@@ -251,5 +250,5 @@ abstract class RESTController extends VoryxController
|
|
|
{
|
|
|
return $entity;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|