Ojs\JournalBundle\Controller\BlockController::createAction PHP Method

createAction() public method

Creates a new Block entity.
public createAction ( Request $request ) : RedirectResponse | Response
$request Symfony\Component\HttpFoundation\Request
return Symfony\Component\HttpFoundation\RedirectResponse | Symfony\Component\HttpFoundation\Response
    public function createAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $journal = $this->get('ojs.journal_service')->getSelectedJournal();
        if (!$this->isGranted('CREATE', $journal, 'block')) {
            throw new AccessDeniedException("You not authorized for this page!");
        }
        $entity = new Block();
        $form = $this->createCreateForm($entity, $journal);
        $form->handleRequest($request);
        if ($form->isValid()) {
            $entity->setJournal($journal);
            $em->persist($entity);
            $em->flush();
            $this->successFlashBag('successful.create');
            return $this->redirectToRoute('ojs_journal_block_show', ['id' => $entity->getId(), 'journalId' => $journal->getId()]);
        }
        return $this->render('OjsJournalBundle:Block:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
    }