[Catalyst-commits] r8359 - in
Catalyst-Runtime/5.80/trunk/lib/Catalyst: . DispatchType
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Fri Sep 5 16:50:16 BST 2008
Author: rafl
Date: 2008-09-05 16:50:16 +0100 (Fri, 05 Sep 2008)
New Revision: 8359
Modified:
Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm
Log:
Make go('/chained/action') execute the full chain, not just the endpoint.
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm 2008-09-05 15:46:25 UTC (rev 8358)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm 2008-09-05 15:50:16 UTC (rev 8359)
@@ -319,6 +319,23 @@
}
+sub expand_action {
+ my ($self, $action) = @_;
+
+ return unless $action->attributes && $action->attributes->{Chained};
+
+ my @chain;
+ my $curr = $action;
+
+ while ($curr) {
+ push @chain, $curr;
+ my $parent = $curr->attributes->{Chained}->[0];
+ $curr = $self->_actions->{$parent};
+ }
+
+ return Catalyst::ActionChain->from_chain([reverse @chain]);
+}
+
__PACKAGE__->meta->make_immutable;
=head1 USAGE
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType.pm 2008-09-05 15:46:25 UTC (rev 8358)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType.pm 2008-09-05 15:50:16 UTC (rev 8359)
@@ -58,6 +58,8 @@
sub uri_for_action { }
+sub expand_action { }
+
=head1 AUTHORS
Catalyst Contributors, see Catalyst.pm
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm 2008-09-05 15:46:25 UTC (rev 8358)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm 2008-09-05 15:50:16 UTC (rev 8359)
@@ -178,6 +178,8 @@
return 0;
}
+ $action = $self->expand_action($action);
+
local $c->request->{arguments} = $args;
$c->namespace($action->namespace);
$c->action($action);
@@ -421,6 +423,17 @@
return undef;
}
+sub expand_action {
+ my ($self, $action) = @_;
+
+ foreach my $dispatch_type (@{ $self->_dispatch_types }) {
+ my $expanded = $dispatch_type->expand_action($action);
+ return $expanded if $expanded;
+ }
+
+ return $action;
+}
+
=head2 $self->register( $c, $action )
Make sure all required dispatch types for this action are loaded, then
More information about the Catalyst-commits
mailing list