Ojs\JournalBundle\Controller\JournalFileController::updateAction PHP Метод

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

Edits an existing Lang entity.
public updateAction ( Request $request, integer $id ) : RedirectResponse | Response
$request Symfony\Component\HttpFoundation\Request
$id integer
Результат Symfony\Component\HttpFoundation\RedirectResponse | Symfony\Component\HttpFoundation\Response
    public function updateAction(Request $request, $id)
    {
        /** @var JournalFile $entity */
        $journal = $this->get('ojs.journal_service')->getSelectedJournal();
        $entity = $this->getDoctrine()->getRepository('OjsJournalBundle:JournalFile')->find($id);
        $this->throw404IfNotFound($entity);
        if (!$this->isGranted('EDIT', $journal, 'files')) {
            throw new AccessDeniedException("You are not authorized for this file!");
        }
        $em = $this->getDoctrine()->getManager();
        $editForm = $this->createEditForm($entity);
        $editForm->handleRequest($request);
        if ($editForm->isValid()) {
            $em->flush();
            $this->successFlashBag('successful.update');
            return $this->redirectToRoute('ojs_journal_filemanager_edit', ['id' => $entity->getId(), 'journalId' => $journal->getId()]);
        }
        return $this->render('OjsJournalBundle:JournalFile:edit.html.twig', array('entity' => $entity, 'edit_form' => $editForm->createView()));
    }