Ojs\ApiBundle\Controller\Admin\PostRestController::putPostAction PHP Метод

putPostAction() публичный Метод

Update existing Post from the submitted data or create a new Post at a specific location.
public putPostAction ( Request $request, integer $id ) : Symfony\Component\Form\FormTypeInterface | FOS\RestBundle\Controller\Annotations\View
$request Symfony\Component\HttpFoundation\Request the request object
$id integer the Post id
Результат Symfony\Component\Form\FormTypeInterface | FOS\RestBundle\Controller\Annotations\View
    public function putPostAction(Request $request, $id)
    {
        if (!$this->isGranted('CREATE', new AdminPost())) {
            throw new AccessDeniedException();
        }
        try {
            if (!($entity = $this->container->get('ojs_api.post.handler')->get($id))) {
                $statusCode = Codes::HTTP_CREATED;
                $entity = $this->container->get('ojs_api.post.handler')->post($request->request->all());
            } else {
                $statusCode = Codes::HTTP_NO_CONTENT;
                $entity = $this->container->get('ojs_api.post.handler')->put($entity, $request->request->all());
            }
            $routeOptions = array('id' => $entity->getId(), '_format' => $request->get('_format'));
            return $this->routeRedirectView('api_1_get_post', $routeOptions, $statusCode);
        } catch (InvalidFormException $exception) {
            return $exception->getForm();
        }
    }