sfPropelActAsRecommendableBehaviorPlugin - 0.1.0
Propel Recommendable behavior
You are currently browsing
the website for symfony 1
This plugin implements a behavior that permits to recommend objects. A recommandation acts as the incrementation of a counter "a la Digg".
|Remi Cieplicki||lead||moc.ega-revelc <<ta>> ikcilpeicr|
Copyright (c) 2007 RÃƒÂ©mi Cieplicki
This plugin implements a behavior that permits to recommend objects. A recommandation acts as the incrementation of a counter "ÃƒÂ la Digg".
go to your project's root
Install the plugin:
./symfony plugin-install http://plugins.symfony-project.com/sfPropelActAsRecommendableBehaviorPlugin
if not already done, enabled behaviors in config/propel.ini:
propel.builder.addBehaviors = true
edit the classes that you want to make Recommendable. For instance, for lib/model/Post.php:
[php] save(); $post->recommend(); // for unregistered users $post->recommend($user->getPrimaryKey()); // $user is a registered user object ### Retrieving one object's recommendation score [php] getRecommendationScore(); echo '
This post has been recommended by '.$score.' users';
The behavior implement the following methods: * recommend($user_id) - add a recommendation on the object (increments the counter). The user id is not mandatory: if not given, a cookie is set to avoid multiple recommendation by a single user * getRecommendationScore() - retrieves the object's score
The plugin has been unit-tested. The tests are located in test/unit/sfPropelActAsRecommendableBehaviorTest.php. If you want to run them: * install the plugin * be sure you are using sfGuardUser object in your application * configure a model for using it, for instance "Post" * edit this file and, if required, modify the application name and the TEST_CLASS constant, line 3:
run the tests:
This plugin is licensed under the MIT license. You can contact the maintainer at firstname.lastname@example.org
Initial public release. Features recommendation for both registered and unregistered users, and score retrieving.