/**
  * Create image
  *
  * @ApiDoc(
  *     views={"default", "image"},
  *     section="Image API",
  *     input={"class"="AppBundle\Form\ImageType", "name"=""},
  *     statusCodes={
  *         201="Returned when successful",
  *         400="Returned when an error has occurred",
  *     }
  * )
  *
  * @Security("is_granted('ROLE_IMAGE_CREATE')")
  *
  * @Route("images", name="api_image_create_image", defaults={"_format": "json"}, methods={"POST"})
  *
  * @param Request $request A Symfony request
  * @return FormInterface|Response
  */
 public function createImageAction(Request $request)
 {
     $formType = new ImageFormType();
     $image = new Image();
     $image->setAuthor($this->getUser());
     $restFormAction = $this->get('glavweb_rest.form_action');
     $actionResponse = $restFormAction->execute(array('request' => $request, 'formType' => $formType, 'entity' => $image, 'onSuccess' => function ($request, $form, Image $image, $response) {
         $response->headers->set('Location', $this->generateUrl('api_image_get_image', array('image' => $image->getId()), true));
     }));
     return $actionResponse->response;
 }