bitheater/rating-bundle

允许对元素进行评分

安装: 21

依赖: 0

建议者: 0

安全: 0

星星: 1

关注者: 3

分支: 0

公开问题: 0

类型:symfony-bundle

dev-master 2015-06-27 11:21 UTC

This package is auto-updated.

Last update: 2024-09-29 03:52:30 UTC


README

此包允许你在网页中包含任何类型的元素评分。

建设中,因此请暂时不要使用此包 :)

安装

  • 将依赖添加到你的 composer.json 文件中: composer require bitheater/rating-bundle
  • AppKernel.php 文件中初始化包:new Bitheater\RatingBundle\BitheaterRatingBundle()
  • 配置包(目前我们只支持MySQL,但支持其他数据存储应该很简单!)
bitheater_rating:
    driver: orm
    model_class: MyBundle\Entity\Vote

创建投票类,继承基本投票类

use Bitheater\RatingBundle\Model\Vote as RatingVote;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="Bitheater\RatingBundle\Repository\Doctrine\ORMRepository")
 * @ORM\Table(name="vote")
 */
class Vote extends RatingVote
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    public function getId()
    {
        return $this->id;
    }
}
  • 完成!现在只需使用该服务即可

$ratingManager = $this->get('bitheater_rating.manager');

享受吧!