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

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

Creates a new ArticleAuthor entity.
public createAction ( Request $request, $articleId ) : RedirectResponse | Response
$request Symfony\Component\HttpFoundation\Request
$articleId
Результат 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();
        $article = $article = $em->getRepository('OjsJournalBundle:Article')->find($articleId);
        if (!$this->isGranted('EDIT', $journal, 'articles')) {
            throw new AccessDeniedException("You not authorized for this page!");
        }
        $entity = new ArticleAuthor();
        $form = $this->createCreateForm($entity, $journal, $article)->add('create', 'submit', array('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_author_index', array('articleId' => $article->getId(), 'journalId' => $journal->getId())));
        }
        return $this->render('OjsJournalBundle:ArticleAuthor:new.html.twig', array('entity' => $entity, 'form' => $form->createView(), 'article' => $article));
    }