I like this solution with postInsert(). It looks better to me than the
listener method :)


On 26 kvě, 23:23, comb <[email protected]> wrote:
> hmm.. you're right.. cannot get the simplest things some times...:-D
> But a last question: Isn't it easier to use the PostInsert Record-Hook
> of the Doctrine_Record than to write a listener-class? or is there
> something wrong with it?
>
> class Comment extends BaseComment{
>     //...
>     public function postInsert()
>     {
>         $record = $this->getRecord(); // i.e. a video-record
>         $record->setNbComments($record->getNbComments()+1);
>     }
>
> }
>
> On 26 Mai, 12:31, Stéphane <[email protected]> wrote:
>
>
>
> > So add a listener to your comment model ! :-)
>
> > Before Printing, Think about Your Environmental Responsibility!
> > Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale!
>
> > On Wed, May 26, 2010 at 12:29 PM, comb <[email protected]> wrote:
> > > Yeah I thought about Listeners, but I can't find the right hook-
> > > point..
> > > In Tom's link that's not the same problem I have... they need the
> > > listener for a model-record, but I need it for the Comments it self
> > > and not for ie the Video-Records.
>
> > > In Commentable-Behavior-Class:
>
> > >        public function setTableDefinition() {
> > >                $this->hasColumn('nb_comments', 'integer', null,
> > > array('default' =>
> > > 0));
> > >                 $this->addListener(new CommentListener($this->_options));
> > >        }
>
> > > This CommentListener only listens to inserts of Records with the
> > > behavior (for example a new Video-post) and not for inserts of a new
> > > Comment!? But I need a HOOK AFTER INSERTING A new COMMENT to increment
> > > the corresponding video_record->nb_comments.
> > > Where is this hook-point?
>
> > > On 25 Mai, 12:42, Stéphane <[email protected]> wrote:
> > > > Hi,
>
> > > > No, think about listeners on Doctrine_Record and the postInsert hook.
>
> > > > Cheers,
>
> > > > Before Printing, Think about Your Environmental Responsibility!
> > > > Avant d'Imprimer, Pensez à Votre Responsabilitée Environnementale!
>
> > > > On Tue, May 25, 2010 at 2:34 AM, comb <[email protected]> wrote:
> > > > > Hi!
>
> > > > > I have a Commentable behavior.
> > > > > Now I want to add a new column nb_comments to a Record with this
> > > > > behavior for performance reasons.
>
> > > > >        public function setTableDefinition() {
> > > > >                $this->hasColumn('nb_comments', 'integer', null,
> > > > > array('default' =>
> > > > > 0));
> > > > > ...
>
> > > > > But where is the best place to increment/decrement the nb_comments
> > > > > attribute? in the Comment-Module-Actions during the processForm/
> > > > > executeDelete is a little dirty, isn't it??
>
> > > > > --
> > > > > If you want to report a vulnerability issue on symfony, please send it
> > > to
> > > > > security at symfony-project.com
>
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "symfony users" group.
> > > > > To post to this group, send email to [email protected]
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]<symfony-users%2bunsubscr...@goog­legroups.com>
> > > <symfony-users%[email protected]<symfony-users%[email protected]>
>
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/symfony-users?hl=en
>
> > > > --
> > > > If you want to report a vulnerability issue on symfony, please send it 
> > > > to
> > > security at symfony-project.com
>
> > > > You received this message because you are subscribed to the Google
> > > > Groups "symfony users" group.
> > > > To post to this group, send email to [email protected]
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<symfony-users%2bunsubscr...@goog­legroups.com>
> > > > For more options, visit this group athttp://
> > > groups.google.com/group/symfony-users?hl=en
>
> > > --
> > > If you want to report a vulnerability issue on symfony, please send it to
> > > security at symfony-project.com
>
> > > You received this message because you are subscribed to the Google
> > > Groups "symfony users" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<symfony-users%2bunsubscr...@goog­legroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/symfony-users?hl=en

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to