• 原文出处:12c-integration_with_fosuserbundle.md

  • 原文作者:FriendsOfSymfony

  • 授权许可:创作共用协议

  • 翻译人员:FireHare

  • 校对人员:

  • 适用版本:FOSCommentBundle 2.0.5

  • 文章状态:草译阶段

Step 12c: Integration with FOSUserBundle

By default, votes are made anonymously.FOSUserBundle authentication can be used to sign the votes.

缺省状态下,投票是匿名的。FOSUserBundle认证可以用来标识投票。


A) Setup FOSUserBundle(安装FOSUserBundle)

First you have to setup FOSUserBundle. Check the instructions.

首先您需要安装 FOSUserBundle。请参阅说明

B) Extend the Vote class(扩展Vote类)

In order to add an author to a vote, the Vote class should implement the SignedVoteInterface and add a field to your mapping.

为了添加投票用户,Vote类需要实现SignedVoteInterface接口并添加一个字段到您的映射中。


For example in the ORM:

ORM示例:

voter = $voter;
    }
    /**
     * Gets the owner of the vote
     *
     * @return UserInterface
     */
    public function getVoter()
    {
        return $this->voter;
    }
}

Back to the main step(返回主步骤)

Step 12: Enable voting.

第12步:启用投票。