symfony
symfony forum
Home » plugins » General plug-ins » sfPropelActAsPolymorphicBehaviorPlugin ALPHA
sfPropelActAsPolymorphicBehaviorPlugin ALPHA [message #35493] Thu, 13 September 2007 14:14 Go to next message
kriswallsmith  is currently offline kriswallsmith
Messages: 43
Registered: September 2007
Location: Portland, Oregon USA
Member
Hi all,

I just posted a wiki page for a plugin I've been working on:

sfPropelActAsPolymorphicBehaviorPlugin

Please take a look and post comments/feedback/criticism here.

Thanks a bunch,
Kris Wallsmith

[Updated on: Thu, 13 September 2007 14:16]

Re: sfPropelActAsPolymorphicBehaviorPlugin ALPHA [message #35522 is a reply to message #35493 ] Thu, 13 September 2007 18:25 Go to previous messageGo to next message
kriswallsmith  is currently offline kriswallsmith
Messages: 43
Registered: September 2007
Location: Portland, Oregon USA
Member
I haven't been able to use sfPropelBehavior::registerMethods() to create methods whose names are based on parameters passed into sfPropelBehavior::add(). To get around this I've recommended users of this plugin create a few wrapper methods for each polymorphic key.

Anyone have any ideas how this could be possible?

Thanks,
k
Re: sfPropelActAsPolymorphicBehaviorPlugin ALPHA [message #35822 is a reply to message #35522 ] Tue, 18 September 2007 09:32 Go to previous messageGo to next message
lajkonik86  is currently offline lajkonik86
Messages: 190
Registered: June 2007
Location: The Netherlands
Senior Member
Just read over the documentation, great concept and plugin.
Re: sfPropelActAsPolymorphicBehaviorPlugin ALPHA [message #41810 is a reply to message #35493 ] Sun, 16 December 2007 19:36 Go to previous messageGo to next message
rupher  is currently offline rupher
Messages: 7
Registered: December 2007
Junior Member
Hi. I installed the plugin and I'm getting this error when I call $post->getComments()

The class "Post" does not have a has_many reference named "comments".

I added this to Post

$hasManyKeys = array('comments' => array('foreign_model' => CommentPeer::SUBJECT_TYPE, 'foreign_id' => CommentPeer::SUBJECT_ID));
sfPropelBehavior::add('Post', array('sfPropelActAsPolymorphic' => array('has_many' => $hasManyKeys)));
sfPropelActAsPolymorphicBehavior::mixinCustomMethods('Post') ;

Also, in the documentation it says, Post will get ->getComments(). What method will be available in Comment? ->getSubject?
Re: sfPropelActAsPolymorphicBehaviorPlugin ALPHA [message #41812 is a reply to message #35493 ] Sun, 16 December 2007 19:51 Go to previous message
rupher  is currently offline rupher
Messages: 7
Registered: December 2007
Junior Member
I looked at the code of the plugin and noticed that it expects foreign_pk not foreign_id.

I changed my code to

$hasManyKeys = array('comments' => array('foreign_model' => CommentPeer::SUBJECT_TYPE, 'foreign_pk' => CommentPeer::SUBJECT_ID));
sfPropelBehavior::add('Post', array('sfPropelActAsPolymorphic' => array('has_many' => $hasManyKeys)));
sfPropelActAsPolymorphicBehavior::mixinCustomMethods('Post');


From the comment object, can I get the object related to it?
Previous Topic:create slug with sfPropelActAsSluggableBehaviorPlugin
Next Topic:sfGuardPlugin install
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software