FOSCommentBundle功能包:设置DoctrineODM映射(投票)

  • 原文出处:12b-mapping_MongoDB.md

    创新互联是一家专业提供建德企业网站建设,专注与成都做网站、成都网站设计、HTML5建站、小程序制作等业务。10年已为建德众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。

  • 原文作者:FriendsOfSymfony

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

  • 翻译人员:FireHare

  • 校对人员:

  • 适用版本:FOSCommentBundle 2.0.5

  • 文章状态:草译阶段

Step 12b: Setup MongoDB mapping

The MongoDB implementation does not provide a concrete Vote class for your use,you must create one:

ROM实现并没有提供一个具体的Vote类给您使用,您需要创建一个:

And you should implement VotableCommentInterface in your Comment class and add a field to your mapping:

并且您需要在您的Comment类中实现 VotableCommentInterface 接口,并添加一个字段到您的映射中:

score = $score;
    }
    /**
     * Returns the current score of the comment.
     *
     * @return integer
     */
    public function getScore()
    {
        return $this->score;
    }
    /**
     * Increments the comment score by the provided
     * value.
     *
     * @param integer value
     *
     * @return integer The new comment score
     */
    public function incrementScore($by = 1)
    {
        $this->score += $by;
    }

Configure your application(配置您的应用程序)

In YAML:

YAML格式:

# app/config/config.yml
fos_comment:
    db_driver: mongodb
    class:
        model:
            vote: MyProject\MyBundle\Document\Vote

Or if you prefer XML:

如果您偏好XML:

# app/config/config.xml

    
        
    

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

Step 12: Enable voting.

第12步:启用投票。
当前题目:FOSCommentBundle功能包:设置DoctrineODM映射(投票)
标题链接:http://csdahua.cn/article/jhoide.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流