![]() |
|
sfPropelActAsCommentableBehaviorPlugin - 0.1.0Propel commentable behavior |
|
![]() |
34
users
Sign-in
to change your status |
This behavior permits to attach comments to Propel objects. |
| Name | Status | |
|---|---|---|
|
|
lead | gro.tocal <<ta>> reivax |
Copyright (c) 2007 Xavier Lacot
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.
| Version | License | API | Released |
|---|---|---|---|
| 1.2.0stable | MIT | 1.2.0stable | 16/01/2009 |
| Version | License | API | Released |
|---|---|---|---|
| 0.5.0beta | MIT | 0.5.0beta | 11/08/2008 |
| 0.4.0beta | MIT license | 0.4.0beta | 10/12/2007 |
| 0.3.0beta | MIT license | 0.3.0beta | 08/10/2007 |
| 0.2.0beta | MIT license | 0.2.0beta | 26/09/2007 |
| 0.1.0beta | MIT license | 0.1.0beta | 13/09/2007 |
Initial public release. Features comments attachment to heterogene Propel objects.
sfPropelActAsCommentableStripper classsf_comment_$id
(Nicolas Perriault)Initial public release. Features comments attachment to heterogene Propel objects.
This behavior permits to attach comments to Propel objects.
go to your project's root
Install the plugin:
./symfony plugin-install http://plugins.symfony-project.com/sfPropelActAsCommentableBehaviorPlugin
if not already done, enabled behaviors in config/propel.ini:
propel.builder.addBehaviors = true
edit the classes that you want to make taggable. For instance, for lib/model/Post.php:
[php]
save();
$post->addComment('This is a cool comment.');
$post->addComment(array('title' => 'this is a cool title', 'text' => 'this is a cool comment', 'author_id' => sfContext::getInstance()->getUser()->getUserId()));
$post->addComment(array('This is a cool comment.', 'this is one other comment'));
### Retrieving one object's tags
It is possible to retrieve tags from a taggable object:
[php]
getTags();
foreach ($tags as $tag)
{
echo $tag.'
';
}
Of course, tags can also be removed:
<?php $post = PostPeer::retrieveByPk(1); $post->removeTag('toto'); $post->removeTag('toto, tutu'); $post->removeAllTags();
The behavior implement the following methods: * addComment($comment) - Adds a comment to the object. The "comment" param can be an associative array (in which each element represents one of the comment properties), or an array of associative arrays. In this case, it adds all the comments to the object. * clearComments() - Deletes all the comments attached to the object * getComments($options = array()) - Returns the list of the comments attached to the object. The options array can contain several options * getNbComments() - Returns the number of the comments attached to the object. * removeComment($comment_id) - Removes one comment from the object.
The behavior class also implement the following method, which is a facility for preloading all the tags for a set of taggable objects * preloadTags($objects) - Preload tags for a set of objects
The plugin has been deeply unit-tested. The tests are located in test/unit/sfPropelActAsCommentableBehaviorTest.php. If you want to run them: * install the plugin * 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:
define('TEST_CLASS', 'Post');
run the tests:
php plugins/sfPropelActAsCommentableBehaviorPlugin/test/unit/sfPropelActAsCommentableBehaviorTest.php
This plugin is licensed under the MIT license. You can contact the maintainer at xavier@lacot.org
Initial public release. Features comments attachment to heterogene Propel objects.
