Ojs\ApiBundle\Controller\Journal\JournalIssueFileRestController::patchFileAction PHP Method

patchFileAction() public method

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