Ojs\AdminBundle\Controller\AdminContactController::createAction PHP Method

createAction() public method

Creates a new JournalContact 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();
        $entity = new JournalContact();
        /** @var $dispatcher EventDispatcherInterface */
        $dispatcher = $this->get('event_dispatcher');
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);
        if ($form->isValid()) {
            $em->persist($entity);
            $em->flush();
            $this->successFlashBag('successful.create');
            $event = new AdminEvent(['eventType' => 'create', 'entity' => $entity]);
            $dispatcher->dispatch(AdminEvents::ADMIN_CONTACT_CHANGE, $event);
            return $this->redirectToRoute('ojs_admin_contact_show', ['id' => $entity->getId()]);
        }
        return $this->render('OjsAdminBundle:AdminContact:new.html.twig', array('entity' => $entity, 'form' => $form->createView()));
    }