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
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.