sfSimpleCommentPlugin - 0.9.2

Comments feature 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

sfSimpleComment plugin (for symfony 1.4)

The sfSimpleCommentPlugin is a symfony plugin that provides basic comments feature for all doctrine models. It's a great bedrock for any more complex comments solutions.

It gives you the basic generic model (comment) and the module (controller and component; frontend only right now) to make any model commentable in a minute.

Installation

  • Install the plugin (via a package)

    symfony plugin:install sfSimpleCommentPlugin
    
  • Install the plugin (via a Subversion checkout)

    svn co http://svn.symfony-project.com/plugins/sfSimpleCommentPlugin plugins/sfSimpleCommentPlugin
    
  • Activate the plugin in the config/ProjectConfiguration.class.php

    class ProjectConfiguration extends sfProjectConfiguration
    {
      public function setup()
      {
        $this->enablePlugins(array(
          'sfSimpleCommentPlugin', 
          '...'
        ));
      }
    }
  • Rebuild your model/classes

    symfony doctrine:build --all
    
  • Enable required module in your settings.yml (optional)

     all:
       .settings:
         enabled_modules:      [default, sfSimpleComment]
    
  • Clear you cache

    symfony cc
    

Use in your application

To use sfSimpleCommentPlugin in symfony application:

  • Enable ability to comment for selected models in app.yml (in other words add requried config entries to your app.yml)

    all:
      [...]
      sfSimpleComment:
        commentable_types: [YourCommentableModel, YourCommentableModel2]
    
  • Inlcude comments list and comment form components on selected pages (like showSuccess template of selected models)

    <?php include_component('sfSimpleComment', 'index', array('commentable' => $yourModelInstance)); ?>
    
    <?php include_component('sfSimpleComment', 'new', array('commentable' => $yourModelInstance)); ?>
    
  • That's all, enjoy :)

(Extend) Convenient connection between comments and commentable models

For each commentable type you can add comment inherited class in project scheme.yml. That will make commenting more strict on code level and gives you possibilty to set default object_type value if you are creating comments out of the default sfSimpleComment module. From other point of view that gives you ability to set neat alias' between commentable type and comment model in doctrine:

  • Example:

    ArticleComment:
      inheritance:
        extends: sfSimpleComment
        type: column_aggregation
        keyField: object_type
        keyValue: Article
      relations:
        Article:
          local: object_id
          foreign: id
          type: one
          foreignType: many
          onDelete: CASCADE
          foreignAlias: Comments
          alias: Article