public function MediaController::updateData in Gutenberg 8.2
Same name and namespace in other branches
- 8 src/Controller/MediaController.php \Drupal\gutenberg\Controller\MediaController::updateData()
Updates file data.
Parameters
\Symfony\Component\HttpFoundation\Request $request: Current request.
string|int $fid: File id.
Return value
\Symfony\Component\HttpFoundation\JsonResponse The JSON response.
Throws
\Symfony\Component\HttpKernel\Exception\HttpException
1 string reference to 'MediaController::updateData'
File
- src/
Controller/ MediaController.php, line 258
Class
- MediaController
- Returns responses for our image routes.
Namespace
Drupal\gutenberg\ControllerCode
public function updateData(Request $request, $fid) {
$data = json_decode($request
->getContent(), TRUE);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new BadRequestHttpException('Request data could not be parsed.');
}
try {
$this->mediaService
->updateMediaData($fid, $data);
} catch (\Throwable $exception) {
return new JsonResponse([
'message' => 'Data could not be updated',
], JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
}
return new JsonResponse([
'status' => 'ok',
]);
}