Skip to content

Commit a9bb4a7

Browse files
committed
Debug rest api
1 parent e0aa453 commit a9bb4a7

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

Controller/ContentManagement/CrudController.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,37 +61,39 @@ public function createAction($ouuid, ContentType $contentType, Request $request)
6161
/**
6262
* @Route("/api/{name}/finalize/{id}", defaults={"_format": "json"})
6363
* @ParamConverter("contentType", options={"mapping": {"name": "name", "deleted": 0, "active": 1}})
64-
* @Method({"GET"})
64+
* @Method({"POST"})
6565
*/
6666
public function finalizeAction($id, ContentType $contentType, Request $request) {
6767

6868
if(!$contentType->getEnvironment()->getManaged()){
6969
throw new BadRequestHttpException('You can not create content for a managed content type');
7070
}
7171

72+
$out = [
73+
'success' => 'false',
74+
];
7275
try {
7376
$revision = $this->dataService()->getRevisionById($id, $contentType);
7477
$newRevision = $this->dataService()->finalizeDraft($revision);
75-
$isFinalize = !$newRevision->getDraft();
78+
$out['success'] = !$newRevision->getDraft();
79+
$out['uuid'] = $newRevision->getOuuid();
7680

7781
} catch (\Exception $e) {
7882
if (($e instanceof NotFoundHttpException) OR ($e instanceof DataStateException)) {
7983
$this->addFlash('error', $e->getMessage());
8084
} else {
8185
$this->addFlash('error', 'The revision ' . $id . ' can not be finalized');
8286
}
83-
$isFinalize = false;
87+
$out['success'] = false;
8488

8589
}
86-
return $this->render( 'EMSCoreBundle:ajax:notification.json.twig', [
87-
'success' => $isFinalize,
88-
]);
90+
return $this->render( 'EMSCoreBundle:ajax:notification.json.twig', $out);
8991
}
9092

9193
/**
9294
* @Route("/api/{name}/discard/{id}", defaults={"_format": "json"})
9395
* @ParamConverter("contentType", options={"mapping": {"name": "name", "deleted": 0, "active": 1}})
94-
* @Method({"GET"})
96+
* @Method({"POST"})
9597
*/
9698
public function discardAction($id, ContentType $contentType, Request $request) {
9799

Resources/views/ajax/notification.json.twig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
{% if warning %}
99
"warning": {{ warning|json_encode|raw }},
1010
{% endif %}
11-
1211
{% set error = app.session.flashbag.get('error') %}
1312
{% if error %}
1413
"error": {{ error|json_encode|raw }},
1514
{% endif %}
16-
{% block body %}{% endblock %}
17-
"success": {{ success|json_encode|raw }}
1815
{% if revision_id is defined %}
1916
"revision_id": {{ revision_id|json_encode|raw }},
2017
{% endif %}
18+
{% if uuid is defined %}
19+
"uuid": {{ uuid|json_encode|raw }},
20+
{% endif %}
21+
{% block body %}{% endblock %}
22+
"success": {{ success|json_encode|raw }}
2123
}

0 commit comments

Comments
 (0)