'error', 'key' => 'cdf', 'method' => '', 'data' => '', ]; $token = $request->headers->get('x-auth-token'); $security->isGranted('MAESTRO_PROJECT_PROJECTS_UPDATE', $token); $data = json_decode($request->getContent(), true); if (!empty($data['version'])) { $list = $cdf->getCdfPagesDuplicate($id, $data['version']); } else { $list = $cdf->getCdfPages($id); } // TODO : Mutualize array controls if (\is_array($list)) { $listProduct = $cdf->getCdfProducts($id); if (\is_array($listProduct)) { $body['type'] = 'success'; $body['data'] = ['pages' => $list, 'products' => $listProduct]; $respond->statusOK(); } else { $type = \gettype($listProduct); $body['method'] = 'getCdfProducts'; $body['data'] = "Expected array, $type received"; $respond->statusUnprocessableEntity(); } } else { $body['method'] = 'getCdfPages'; if ($list instanceof Exception) { $body['data'] = $list->getMessage(); } else { $type = \gettype($list); $body['data'] = "Expected array, $type received"; } $respond->statusUnprocessableEntity(); } return $respond->createBody($body)->respond(); } }