|
@@ -155,11 +155,17 @@ class ONURESTController extends RESTController
|
|
$newState = $wf->apply($entity, $transition);
|
|
$newState = $wf->apply($entity, $transition);
|
|
|
|
|
|
$em = $this->container->get("doctrine.orm.entity_manager");
|
|
$em = $this->container->get("doctrine.orm.entity_manager");
|
|
- $em->persist($entity);
|
|
|
|
- $em->flush();
|
|
|
|
-
|
|
|
|
- return $entity;
|
|
|
|
|
|
+ $validator = $this->container->get('validator');
|
|
|
|
+ $errors = $validator->validate($entity);
|
|
|
|
+ if (count($errors) > 0) {
|
|
|
|
+ $errorsString = (string) $errors;
|
|
|
|
+ return FOSView::create($errorsString, Codes::HTTP_INTERNAL_SERVER_ERROR);
|
|
|
|
+ }else{
|
|
|
|
+ $em->persist($entity);
|
|
|
|
+ $em->flush();
|
|
|
|
|
|
|
|
+ return $entity;
|
|
|
|
+ }
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR);
|
|
return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR);
|
|
}
|
|
}
|