public function putPublisherAction(Request $request, $id)
{
if (!$this->isGranted('CREATE', new Publisher())) {
throw new AccessDeniedException();
}
try {
if (!($entity = $this->container->get('ojs_api.publisher.handler')->get($id))) {
$statusCode = Codes::HTTP_CREATED;
$entity = $this->container->get('ojs_api.publisher.handler')->post($request->request->all());
} else {
$statusCode = Codes::HTTP_NO_CONTENT;
$entity = $this->container->get('ojs_api.publisher.handler')->put($entity, $request->request->all());
}
$routeOptions = array('id' => $entity->getId(), '_format' => $request->get('_format'));
return $this->routeRedirectView('api_1_get_publisher', $routeOptions, $statusCode);
} catch (InvalidFormException $exception) {
return $exception->getForm();
}
}