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

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

Creates a new IssueFile entity.
public createAction ( Request $request, $issueId ) : RedirectResponse | Response
$request Symfony\Component\HttpFoundation\Request
$issueId
Результат Symfony\Component\HttpFoundation\RedirectResponse | Symfony\Component\HttpFoundation\Response
    public function createAction(Request $request, $issueId)
    {
        $journal = $this->get('ojs.journal_service')->getSelectedJournal();
        $em = $this->getDoctrine()->getManager();
        if (!$this->isGranted('CREATE', $journal, 'issues')) {
            throw new AccessDeniedException('You are not authorized for create  issue file for this journal!');
        }
        /** @var Issue $issue */
        $issue = $em->getRepository('OjsJournalBundle:Issue')->find($issueId);
        $this->throw404IfNotFound($issue);
        $entity = new IssueFile();
        $entity->setIssue($issue);
        $form = $this->createCreateForm($entity, $journal->getId())->add('create', 'submit', array('label' => 'c'));
        $form->handleRequest($request);
        if ($form->isValid()) {
            /** @var EntityManager $em */
            $em = $this->getDoctrine()->getManager();
            $entity->setIssue($issue);
            $em->persist($entity);
            $em->flush();
            return $this->redirect($this->generateUrl('ojs_journal_issue_file_edit', ['id' => $entity->getId(), 'journalId' => $journal->getId(), 'issueId' => $issue->getId()]));
        }
        return $this->render('OjsJournalBundle:IssueFile:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
    }