[Catalyst] Dynamically adding ActionClass

John Napiorkowski jjn1056 at yahoo.com
Fri Oct 6 21:07:38 CEST 2006


--- Juan Camacho <jc5826 at gmail.com> wrote:

> I have an existing catalyst plugin where I would
> like to set a stash
> item after the Controller is called but before the
> View is executed.
> One way of doing this is by simply creating a custom
> ActionClass that
> sets the stash item.  Is there a way to dynamically
> add an ActionClass
> from within the plugin code? I want to avoid adding
> instructions for
> existing plugin users to write "sub foo :
> ActionClass('Bar')" in their
> controllers, and breaking backward compatability.
> 
> Besides the ActionClass approach is there another
> way to do this?
> Juan
> 

If you make a custom Controller class you can add in
your ActionClasses like so:

__PACKAGE__->_action_class('My::Action::Class');

(Example from an email from Matt Trout)

That way you don't have to add the ActionClass
attribute to an action, although it will mean all
actions in that controller will share that action
class (may or may not be trouble).  However I don't
think this really does what you need.

--john

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Catalyst mailing list