[Catalyst-dev] question about Catalyst::Manual::Actions
Matt S Trout
dbix-class at trout.me.uk
Fri Jul 7 15:59:43 CEST 2006
John Napiorkowski wrote:
> Hi,
>
> This actions section is a great addition and I see immediate uses for it. However I have a question about the docs. It gives and example of a BEFORE action:
>
> #--------------------------------------#
> package Catalyst::Action::SayBefore;
>
> use base 'Catalyst::Action';
>
> sub execute {
> my $self = shift;
> my ( $controller, $c, $test ) = @_;
> $c->stash->{what} = 'world';
> $self->NEXT::execute( @_ );
> };
>
> 1;
> #--------------------------------------#
>
> Would an AFTER action look like this?
>
> #--------------------------------------#
> package Catalyst::Action::SayBefore;
>
> use base 'Catalyst::Action';
>
> sub execute {
> my $self = shift;
my ( $controller, $c, $test ) = @_;
$self->NEXT::execute( @_ );
> ## Anything you want to do after the action runs
> ## but before it continues.
>
> };
>
> 1;
> #--------------------------------------#
> If I have this right is there still time for me to submit a docs patch? I found I read it
> few times before I grasped that I could do an after action. I think it work clarify
> things a bit. I really see the possibility that there will be a whole host of contributed
> actions on this model.
c.f. my tweaks to your code - Catalyst::Action::RenderView is a "real" example
of this.
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Catalyst-dev
mailing list