Ojs\JournalBundle\Controller\ArticleFileController::createAction PHP Метод

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

Creates a new ArticleFile entity.
public createAction ( Request $request, integer $articleId ) : RedirectResponse | Response
$request Symfony\Component\HttpFoundation\Request
$articleId integer
Результат Symfony\Component\HttpFoundation\RedirectResponse | Symfony\Component\HttpFoundation\Response
    public function createAction(Request $request, $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);
        $entity = new ArticleFile();
        $form = $this->createCreateForm($entity, $journal, $article)->add('create', 'submit', ['label' => 'c']);
        $form->handleRequest($request);
        if ($form->isValid()) {
            $entity->setArticle($article);
            $em->persist($entity);
            $em->flush();
            $this->successFlashBag('successful.create');
            return $this->redirect($this->generateUrl('ojs_journal_article_file_index', ['articleId' => $article->getId(), 'journalId' => $journal->getId()]));
        }
        return $this->render('OjsJournalBundle:ArticleFile:new.html.twig', ['entity' => $entity, 'form' => $form->createView()]);
    }