Ojs\JournalBundle\Controller\ArticleFileController::updateAction PHP Method

updateAction() public method

Edits an existing ArticleFile entity.
public updateAction ( Request $request, integer $id, integer $articleId ) : RedirectResponse | Response
$request Symfony\Component\HttpFoundation\Request
$id integer
$articleId integer
return Symfony\Component\HttpFoundation\RedirectResponse | Symfony\Component\HttpFoundation\Response
    public function updateAction(Request $request, $id, $articleId)
    {
        $journalService = $this->get('ojs.journal_service');
        $journal = $journalService->getSelectedJournal();
        $em = $this->getDoctrine()->getManager();
        if (!$this->isGranted('EDIT', $journal, 'articles')) {
            throw new AccessDeniedException("You not authorized for this page!");
        }
        /** @var Article $article */
        $article = $em->getRepository('OjsJournalBundle:Article')->find($articleId);
        $this->throw404IfNotFound($article);
        /** @var ArticleFile $entity */
        $entity = $em->getRepository('OjsJournalBundle:ArticleFile')->findOneBy(['article' => $article, 'id' => $id]);
        $this->throw404IfNotFound($entity);
        $editForm = $this->createEditForm($entity, $journal, $article)->add('save', 'submit', ['label' => 'save']);
        $editForm->handleRequest($request);
        if ($editForm->isValid()) {
            $em->flush();
            $this->successFlashBag('successful.update');
            return $this->redirect($this->generateUrl('ojs_journal_article_file_edit', ['id' => $id, 'journalId' => $journal->getId(), 'articleId' => $article->getId()]));
        }
        return $this->render('OjsJournalBundle:ArticleFile:edit.html.twig', ['entity' => $entity, 'edit_form' => $editForm->createView()]);
    }