sfDoctrineActAsRattablePlugin - 0.0.1

sfDoctrineActAsRattable Plugin

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

sfDoctrineActAsRattablePlugin

Introduction

This plugin permits to attach rates to Doctrine objects

You can discuss about this plugin on the google group sfDoctrineActAsRattable

Full (and up to date) documentation available on the symfony wiki

Features

  • add/remove ratings
  • manage multiple ratings
  • get average rating
  • get commented ratings
  • be notified when an object is rated

How it works

Giving Rattable behavior to an object the same as Doctrine I18n

It create an object_rate table with how many column as criterias OR default one : rate

Example :

hotel_room:
  actAs: 
    Rattable:
      criterias: [clean_state, receptionist, equipment]
      max_rate: 5
      rounding_rate: 1

Will create 2 tables:

 1 hotel_room
 1 hotel_room_rate, with columns:
     clean_state
     reception
     equipment
     comment
     user_id # foreignKey to sfGuardUser if exists

Installation

Symfony way

  • go to your project's root
  • Install the plugin:

    ./symfony plugin-install http://svn.symfony-project.com/plugins/sfDoctrineActAsRattblePlugin/branches/1.2
    

SVN way

  • from the terminal, go to your plugin directory:
  • enter

    svn pe svn:externals .
    
  • write add a line

    sfDoctrineActAsRattblePlugin http://svn.symfony-project.com/plugins/sfDoctrineActAsRattblePlugin/branches/1.2
    
  • close the editor

  • do a svn update an that's all

Configuration

  • configure your object :

    my_object:
      actAs:
        Rattable:
          criterias:     rate # or [clean_state, receptionist, equipment] only if you wanna rate specifics parts
          max_rate:      5    # 2,10 etc. any integer number you want (more than 20 is a bad idea, work with rounding instead)
          rounding_rate: 1    # or 0.1, 0.2 etc.
          with_comment:  true # false
    
  • rebuild the model:

    ./symfony doctrine-build-all
    
  • clear cache:

    ./symfony cc
    

API

The plugin implements the following methods to the object:

  • getRates()
  • getRating()
  • addRate(RategObject $rateObject)
  • removeRatings()
  • getRatesQuery()

Events notifications types

  • rate.add notify
  • rate.remove notify

Helpers

Examples

Todo

  • notification management
  • give examples
  • create helpers
  • create components to show ratings
  • add icons possibility for ratings types

Unit testing

The plugin has been unit-tested, perhaps not fully (I'm a newbie in unit tests). The tests are located in developpment branch.

Side notes

I won't release pear packages, if someone is interested in managing them, let met know and I will add you as package manager.

License and credits

This plugin has been created by Mickael Kurmann and is licensed under the MIT license.

I took my inspiration from :