2017 © Pedro Peláez
 

symfony-bundle rating-bundle

Symfony2 Star Rating Bundle

image

avro/rating-bundle

Symfony2 Star Rating Bundle

  • Wednesday, September 5, 2012
  • by jdewit
  • Repository
  • 0 Watchers
  • 0 Stars
  • 78 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

AvroRatingBundle

Add a star rating to any object., (*1)

Status

  • A work in progress
  • Currently only works with MongoDB

Requirements

Installation

Download AvroRatingBundle using composer

Add AvroRatingBundle in your composer.json:, (*2)

{
    "require": {
        "avro/rating-bundle": "*"
    }
}

Now tell composer to download the bundle by running the command:, (*3)

``` bash $ php composer.phar update avro/rating-bundle, (*4)


### Enable the bundle in the kernel: ``` php // app/AppKernel.php new Avro\RatingBundle\AvroRatingBundle

Add Resources

Add CSS ``` html {% stylesheets output='css/compiled/app.css' filter='cssrewrite, less, ?yui_css' ... 'bundles/avrorating/css/avro-rating.css' ... %} {% endstylesheets %}, (*5)

Add JS
``` html
{% javascripts output='js/compiled/app.js' filter='?yui_js'
...
    'bundles/avrorating/js/avro-rating.js'
...
%}
    
{% endjavascripts %}

Dump your assets and watch ``` bash $ php app/console assets:install --symlink=true, (*6)

$ php app/console assetic:dump --watch --force, (*7)


Configuration ------------- No configuration is necessary but does come with some options that allow you to customize it ``` yaml avro_rating: template: 'AvroRatingBundle:Rating:rating.html.twig star_count: 5 min_role: ROLE_USER

Usage

Add the rating reference to the object you want to rate, (*8)

``` php <?php // src/Acme/ProductBundle/Document/Product.php, (*9)

namespace Acme\ProductBundle\Document;, (*10)

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;, (*11)

/** * @ODM\Document */ class Product { ..., (*12)

/**
 * @ODM\ReferenceOne(targetDocument="Avro\RatingBundle\Document\Rating", cascade={"all"})
 */
protected $rating;

/**
 * Set rating
 *
 * @param Avro\RatingBundle\Document\Rating $rating
 * @return Product
 */
public function setRating(\Avro\RatingBundle\Document\Rating $rating)
{
    $this->rating = $rating;
    return $this;
}

/**
 * Get rating
 *
 * @return Avro\RatingBundle\Document\Rating $rating
 */
public function getRating()
{
    return $this->rating;
}

...

}, (*13)


Render the rating in your view ``` html {{ avro_rating(product.rating) }}

And that's it!, (*14)

TODO

  1. ORM support
  2. Add configuration

The Versions

05/09 2012

dev-master

9999999-dev http://github.com/avro/AvroRatingBundle

Symfony2 Star Rating Bundle

  Sources   Download

MIT

The Requires

 

by Joris de Wit