|
@@ -36,7 +36,6 @@ abstract class RESTController extends VoryxController
|
|
|
* @View(serializerEnableMaxDepthChecks=true)
|
|
|
*
|
|
|
* @param ParamFetcherInterface $paramFetcher
|
|
|
- * @param string $repository
|
|
|
*
|
|
|
* @return Response
|
|
|
*
|
|
@@ -151,6 +150,24 @@ abstract class RESTController extends VoryxController
|
|
|
return $this->getDoctrine()->getRepository($entity)->findOneBy(array('id' => $id));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Funcion que busca el nombre de los campos que poseen error.
|
|
|
+ * @param Form $form Contiene el formulario.
|
|
|
+ * @return array Retorna un array con los nombre de los campos invalidos para el formulario.
|
|
|
+ */
|
|
|
+ private function getFormFieldError(Form $form)
|
|
|
+ {
|
|
|
+ $errorField = array();
|
|
|
+ foreach ($form as $child) {
|
|
|
+ if ($child->isSubmitted() && $child->isValid()) {
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ $errorField[] = $child->getName();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @return object Retorna el objeto tenencia.
|
|
|
*/
|
|
@@ -188,7 +205,7 @@ abstract class RESTController extends VoryxController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Create a Client entity.
|
|
|
+ * Create a entity.
|
|
|
*
|
|
|
* @View(statusCode=201, serializerEnableMaxDepthChecks=true)
|
|
|
*
|
|
@@ -207,12 +224,14 @@ abstract class RESTController extends VoryxController
|
|
|
$em->persist($entity);
|
|
|
$em->flush();
|
|
|
return $entity;
|
|
|
+ } else {
|
|
|
+ var_dump($this->getFormFieldError($form));
|
|
|
}
|
|
|
return FOSView::create(array('errors' => $form->getErrors()), Codes::HTTP_INTERNAL_SERVER_ERROR);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Update a Client entity.
|
|
|
+ * Update a entity.
|
|
|
*
|
|
|
* @View(serializerEnableMaxDepthChecks=true)
|
|
|
*
|
|
@@ -242,6 +261,8 @@ abstract class RESTController extends VoryxController
|
|
|
// actualizo los datos.
|
|
|
$em->flush();
|
|
|
return $entity;
|
|
|
+ } else {
|
|
|
+ var_dump($this->getFormFieldError($form));
|
|
|
}
|
|
|
return FOSView::create(array('errors' => $form->getErrors()), Codes::HTTP_INTERNAL_SERVER_ERROR);
|
|
|
} catch (\Exception $e) {
|
|
@@ -250,7 +271,7 @@ abstract class RESTController extends VoryxController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Partial Update to a Client entity.
|
|
|
+ * Partial Update to a entity.
|
|
|
*
|
|
|
* @View(serializerEnableMaxDepthChecks=true)
|
|
|
*
|
|
@@ -265,7 +286,7 @@ abstract class RESTController extends VoryxController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Delete a Client entity.
|
|
|
+ * Delete a entity.
|
|
|
*
|
|
|
* @View(statusCode=204)
|
|
|
*
|
|
@@ -288,7 +309,7 @@ abstract class RESTController extends VoryxController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Get a Client entity
|
|
|
+ * Get a entity
|
|
|
*
|
|
|
* @View(serializerEnableMaxDepthChecks=true)
|
|
|
*
|