diff --git a/lib/RoadizCoreBundle/src/Security/Authorization/AccessDeniedHandler.php b/lib/RoadizCoreBundle/src/Security/Authorization/AccessDeniedHandler.php index adf23d44..ff05c9e3 100644 --- a/lib/RoadizCoreBundle/src/Security/Authorization/AccessDeniedHandler.php +++ b/lib/RoadizCoreBundle/src/Security/Authorization/AccessDeniedHandler.php @@ -44,7 +44,7 @@ public function __construct( } /** - * Handles an access denied failure redirecting to home page + * Handles access denied failure redirecting to home page * * @param Request $request * @param AccessDeniedException $accessDeniedException diff --git a/lib/Rozier/src/Controllers/Nodes/NodesAttributesController.php b/lib/Rozier/src/Controllers/Nodes/NodesAttributesController.php index aed3ef6b..1e6688d7 100644 --- a/lib/Rozier/src/Controllers/Nodes/NodesAttributesController.php +++ b/lib/Rozier/src/Controllers/Nodes/NodesAttributesController.php @@ -71,6 +71,14 @@ public function editAction(Request $request, int $nodeId, int $translationId): R return $response; } + $isJson = + $request->isXmlHttpRequest() || + $request->getRequestFormat('html') === 'json' || + \in_array( + 'application/json', + $request->getAcceptableContentTypes() + ); + $this->assignation['attribute_value_translation_forms'] = []; $attributeValues = $node->getAttributeValues(); /** @var AttributeValue $attributeValue */ @@ -108,7 +116,7 @@ public function editAction(Request $request, int $nodeId, int $translationId): R ); $this->publishConfirmMessage($request, $msg, $nodeSource); - if ($request->isXmlHttpRequest() || $request->getRequestFormat('html') === 'json') { + if ($isJson) { return new JsonResponse([ 'status' => 'success', 'message' => $msg, @@ -123,7 +131,7 @@ public function editAction(Request $request, int $nodeId, int $translationId): R /* * Handle errors when Ajax POST requests */ - if ($request->isXmlHttpRequest() || $request->getRequestFormat('html') === 'json') { + if ($isJson) { return new JsonResponse([ 'status' => 'fail', 'errors' => $errors, diff --git a/lib/Rozier/src/Controllers/Tags/TagsController.php b/lib/Rozier/src/Controllers/Tags/TagsController.php index 10baa025..a32b2daa 100644 --- a/lib/Rozier/src/Controllers/Tags/TagsController.php +++ b/lib/Rozier/src/Controllers/Tags/TagsController.php @@ -380,6 +380,10 @@ public function editSettingsAction(Request $request, int $tagId): Response ]); $form->handleRequest($request); + $isJsonRequest = + $request->isXmlHttpRequest() || + \in_array('application/json', $request->getAcceptableContentTypes()) + ; if ($form->isSubmitted()) { if ($form->isValid()) { @@ -403,7 +407,7 @@ public function editSettingsAction(Request $request, int $tagId): Response /* * Handle errors when Ajax POST requests */ - if ($request->isXmlHttpRequest()) { + if ($isJsonRequest) { $errors = $this->getErrorsAsArray($form); return new JsonResponse([ 'status' => 'fail',