sfPropelSpamTagBehaviorPlugin - 0.9.0

Spam Tag behavior for Propel.

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 | Show as Markdown

sfPropelSpamTagBehaviorPlugin plugin

The sfPropelSpamTagBehaviorPlugin is a symfony plugin that provides a new Propel behavior.

If you enable this behavior for one of your model class, all objects of this class with the attribute is_spam set to true will no longer appear on database requests. etion.

Installation

  • Install the plugin

      symfony plugin-install http://plugins.symfony-project.com/sfPropelSpamTagBehaviorPlugin
    
  • Enable Propel behavior support in propel.ini:

      propel.builder.AddBehaviors = true
    

    If you have to enable the behavior support, rebuild your model:

      symfony propel-build-model
    
  • Activate the behavior for one of your Propel model:

      // lib/model/Comment.php
      class Comment
      {
      }
    
      sfPropelBehavior::add('Comment', array('spamTag'));
    

    By default, the plugin will consider the is_spam column for this model. You can also specify another column:

      sfPropelBehavior::add('Comment', array('spamTag' => array('column' => 'tagged_as_spam')));
    

Usage

Here are some examples of Propel calls and the generated SQL:

$articles = CommentPeer::doSelect(new Criteria());
// Generates in SQL
SELECT blog_comment.ID, blog_comment.AUTHOR_ID, blog_comment.CREATED_AT, blog_article.BODY, blog_article.IS_SPAM FROM blog_comment
WHERE blog_comment.IS_SPAM = 0

$article = Comment::retrieveByPK(1);
// Generates in SQL
SELECT blog_comment.ID, blog_comment.AUTHOR_ID, blog_comment.CREATED_AT, blog_article.BODY, blog_article.IS_SPAM FROM blog_comment
WHERE blog_comment.ID=1 AND blog_comment.IS_SPAM = 0

$articles = CommentPeer::doCount(new Criteria());
// Generates in SQL
SELECT COUNT(blog_comment.ID) FROM blog_comment WHERE blog_comment.IS_SPAM = 0

You can also disable the behavior with:

  sfPropelSpamTagBehavior::disable();

This ill allow you to query the database for tagged records. Don't forget to enable the behavior again afterwards:

  sfPropelSpamTagBehavior::enable();

Changelog

2007-03-23 | 0.9.0 Beta

  • francois: Initial release