X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;h=cb22e63a6b9b6fa824bf2a9455e2090117ca8fc0;hp=3a97c87f9f83664ac3174e45313e75e465a142f2;hb=1315d253bbf854cbd9740ef4323a9930411b9fa0;hpb=2ee0056ea3edb67a476aadeac450afdb3a5286d8 diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 3a97c87..cb22e63 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -531,9 +531,29 @@ sub register { } } + my @dtypes = @{ $self->_dispatch_types }; + my @normal_dtypes; + my @low_precedence_dtypes; + + while (my $type = shift @dtypes) { + if ($type->isa('Catalyst::DispatchType::Index') || + $type->isa('Catalyst::DispatchType::Default')) { + push @low_precedence_dtypes, $type; + } else { + push @normal_dtypes, $type; + } + } + # Pass the action to our dispatch types so they can register it if reqd. - foreach my $type ( @{ $self->_dispatch_types } ) { - $type->register( $c, $action ); + my $was_registered = 0; + foreach my $type ( @normal_dtypes ) { + $was_registered = 1 if $type->register( $c, $action ); + } + + if (not $was_registered) { + foreach my $type ( @low_precedence_dtypes ) { + $type->register( $c, $action ); + } } my $namespace = $action->namespace;