That I don't understand very well is the system of Observer. Here that I understand about this : I need to create my own Observer, for example "comment.php" stored in fuel/app/classes/observer/comment.php :
class Observer_Comment extends Orm\Observer
{
public function after_save(Orm\Model $model)
{
$model->nb_comments++;
}
}
And in my model comment.php stored in fuel//app/classes/model/comment.php :
protected static $_observers = array(
'Orm\Observer_Comment' => array(
'events' => array('after_save')
),
);
That I don't understand is how my Observer know what model to use ? In my case, $model must be Model_Post but I don't know ho to specify this.
Ok I understand for the object to pass to the Observer. But in my case, I want that when a new comment is saved, the counter nb_comments of Model_Post is updated. So, the Observer is obligatory on my Model_Comment no ?
How to listen when a new Model_Comment is added adding an Observer in my Model_Post ?