Hello,

I have some trouble with a project I'm building with symfony 1.4 &
doctrine 1.2. I have a Page and a Tag model. They're bound through a
PageTag refClass in a m2m relationship.

Since the tag class is also bound to several other models, I'm trying
to keep track of a tag's associations into the tags' table. I added a
column 'associations_count' to the Tag schema, and added two methods
to the model to increment or decrement this property. So far so good.

Incrementing the counter when a new PageTag object is created works
like a charm. I override the preInsert method, and it works.

But decrementing does not work that easily. My first idea was to
override the preDelete method:
class PageTag extends BasePageTag
{
        ...

        public function preDelete($event)
        {
                $this->Tag->decrement()->save();
                return parent::preDelete($event);
        }
}

This code is not executed when you break the link between a Page and a
Tag in the generated admin. I've also tried to override the delete
method, with the same (lack of) result.  If I write this :
class PageTag extends BasePageTag
{
        ...

        public function delete(Doctrine_Connection $conn  = null)
        {
                die('foo');
                $this->Tag->decrement()->save();
                return parent::delete($conn);
        }
}

The corresponding row is removed from the page_tag table. Doctrine
does not hydrate the records to delete them.

My question is : how can I hook in the record's removal process ?


Thank you for your help ;)

-- 
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 symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to