400 028 6601

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

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

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映射(投票)
URL标题:http://mbwzsj.com/article/jhoide.html

其他资讯

让你的专属顾问为你服务