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

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

Creates a new PublisherTheme entity.
public createAction ( integer $publisherId, Request $request ) : RedirectResponse | Response
$publisherId integer
$request Symfony\Component\HttpFoundation\Request
Результат Symfony\Component\HttpFoundation\RedirectResponse | Symfony\Component\HttpFoundation\Response
    public function createAction($publisherId, Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $publisher = $em->getRepository('OjsJournalBundle:Publisher')->find($publisherId);
        $this->throw404IfNotFound($publisher);
        if (!$this->isGrantedForPublisher($publisher)) {
            throw new AccessDeniedException("You are not authorized for this page!");
        }
        $entity = new PublisherTheme();
        $form = $this->createCreateForm($entity, $publisher);
        $form->handleRequest($request);
        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $entity->setPublisher($publisher);
            $em->persist($entity);
            $em->flush();
            $this->successFlashBag('successful.create');
            return $this->redirectToRoute('ojs_publisher_manager_theme_show', ['publisherId' => $publisher->getId(), 'id' => $entity->getId()]);
        }
        return $this->render('OjsJournalBundle:ManagerPublisherTheme:new.html.twig', array('entity' => $entity, 'publisher' => $publisher, 'form' => $form->createView()));
    }