src/PHPDish/Bundle/PostBundle/Service/PostManager.php
public function addVoter(PostInterface $post, UserInterface $user)
    {
        $post->addVoter($user)
            ->addVoteCount();
        $this->entityManager->persist($post);
        $this->entityManager->flush();

        //触发事件
        $this->eventDispatcher->dispatch(Events::POST_VOTED,
            new VotePostEvent($post, $user)
        );
    }
public function addVoter(PostInterface $post, UserInterface $user)
    {
        $post->addVoter($user)
            ->addVoteCount();
        $this->entityManager->persist($post);
        $this->entityManager->flush();

        //触发事件
        $this->eventDispatcher->dispatch(Events::POST_VOTED,
            new VotePostEvent($post, $user)
        );
    }
{@inheritdoc}