Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

multi-inh

  • Loading branch information...
commit 02d16094cc75e5828ec1ec5ababbe9e035cfc1ed 1 parent 74f32d7
Zbigniew Lukasiak authored
View
5 lib/WebNano/Controller.pm
@@ -52,7 +52,10 @@ sub handle {
my ( $class, %args ) = @_;
my $path = delete $args{path};
my $self = $class->new( %args );
- return $self->local_dispatch( @$path );
+ my $out = $self->local_dispatch( @$path );
+ return $out if defined( $out );
+ return $self->external_dispatch( path => $path, %args ) if $self->can( 'external_dispatch' );
+ return;
};
1;
View
18 lib/WebNano/DirController.pm
@@ -3,28 +3,26 @@ use warnings;
package WebNano::DirController;
use WebNano::FindController 'find_nested';
-use base 'WebNano::Controller';
+#use base 'WebNano::Controller';
sub _self_path{
- my $class = shift;
- my $path = $class;
+ my $self = shift;
+ my $path = ref $self;
$path =~ s/.*::Controller(?=(::|$))//;
$path =~ s{::}{/};
return $path . '/';
}
-sub handle {
- my ( $class, %args ) = @_;
+sub external_dispatch {
+ my ( $self, %args ) = @_;
my $path = delete $args{path};
- my $self = $class->new( %args );
- my $out = $self->local_dispatch( @$path );
- return $out if defined( $out );
my $path_part = shift @$path;
$path_part =~ s/::|'//g if defined( $path_part );
return if !length( $path_part );
- my $controller_class = find_nested( $class->_self_path . $path_part, $args{app}->controller_search_path );
+ my $controller_class = find_nested( $self->_self_path . $path_part, $self->app->controller_search_path );
if( !$controller_class ){
- warn qq{No subcontroller found in "$class" for "} . $class->_self_path . $path_part . qq{"\n} if $self->DEBUG;
+ my $class = ref $self;
+ warn qq{No subcontroller found in "$class" for "} . $self->_self_path . $path_part . qq{"\n} if $self->DEBUG;
return;
}
warn qq{Dispatching to "$controller_class"\n} if $self->DEBUG;
View
2  t/lib/MyApp/Controller.pm
@@ -3,7 +3,7 @@ use warnings;
package MyApp::Controller;
-use base 'WebNano::DirController';
+use base 'WebNano::Controller', 'WebNano::DirController';
sub new {
my $class = shift;
View
2  t/lib/MyApp/Controller/Deep.pm
@@ -3,6 +3,6 @@ use warnings;
package MyApp::Controller::Deep;
-use base 'WebNano::DirController';
+use base 'WebNano::Controller', 'WebNano::DirController';
1;

0 comments on commit 02d1609

Please sign in to comment.
Something went wrong with that request. Please try again.