src/PHPDish/Bundle/ForumBundle/Controller/TopicController.php
public function createAction(Request $request)
    {
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
        $manager = $this->getTopicManager();
        $topic = $manager->createTopic($this->getUser());
        $form = $this->createForm(TopicType::class, $topic);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $manager->saveTopic($topic);
            //触发事件
            $this->get('event_dispatcher')->dispatch(Events::TOPIC_CREATED, new TopicEvent($topic));

            return $this->redirectToRoute('topic_view', [
                'id' => $topic->getId(),
            ]);
        }

        return $this->render($this->configuration->getTemplate('Topic:create.html.twig'), [
            'form' => $form->createView(),
            'threads' => $this->getThreadManager()->findEnabledThreads(10)
        ]);
    }
public function createAction(Request $request)
    {
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
        $manager = $this->getTopicManager();
        $topic = $manager->createTopic($this->getUser());
        $form = $this->createForm(TopicType::class, $topic);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $manager->saveTopic($topic);
            //触发事件
            $this->get('event_dispatcher')->dispatch(Events::TOPIC_CREATED, new TopicEvent($topic));

            return $this->redirectToRoute('topic_view', [
                'id' => $topic->getId(),
            ]);
        }

        return $this->render($this->configuration->getTemplate('Topic:create.html.twig'), [
            'form' => $form->createView(),
            'threads' => $this->getThreadManager()->findEnabledThreads(10)
        ]);
    }
创建话题.

@Route("/topics/new", name="topic_add")

@param Request $request

@return Response