Ojs\ApiBundle\Controller\Admin\IndexRestController::putIndexesAction PHP Method

putIndexesAction() public method

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