Behaviour Commentable

class Nos\Comments\Orm_Behaviour_Commentable

Adds the ability to use the Comment API on an a Nos\Orm\Model.

Methods

static Nos\Comments\Orm_Behaviour_Commentable::commentApi
Returns:An instance of Nos\Comments\Api`, configured for this item.
Nos\Comments\Orm_Behaviour_Commentable::count_comments()

Returns and caches the number of comments related to one item

Returns:Number of comments
Nos\Comments\Orm_Behaviour_Commentable::setNbComments($nb)

Allow to enter a custom cached number of comments related to the item. Can be useful when adding or removing a comment for instance.

Parameters:
  • $nb – number of comments
static Nos\Comments\Orm_Behaviour_Commentable::count_multiple_comments($items)

From a items’ list, retrieve the number of comments in an optimal way.

Parameters:
  • $items

Relations

This behaviour adds a comments relation to retrieve all the published comments of the Model.

Others

  • This behaviours adds a Comments action on the Model’s App Desk, which will open a tab listing all the comments of the item.
  • This behaviours adds a Comments column in the App Desk, containing the number of comments for each item.

Example

<?php

class Model_Monkey extends \Nos\Orm\Model
{
        protected static $_behaviours = array(
                'Nos\Comments\Orm_Behaviour_Commentable' => array(
                ),
        );
}