Ojs\ApiBundle\Controller\Admin\PeriodRestController::patchPeriodAction PHP Method

patchPeriodAction() public method

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