From: André Walker Date: Mon, 11 Jul 2011 16:05:31 +0000 (-0300) Subject: ->controller changes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=d0354b83c4f17ad335d09394a335f86bd77906a1 ->controller changes --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 46d0e8b..e071663 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -558,10 +558,18 @@ If you want to search for controllers, pass in a regexp as the argument. sub controller { my ( $c, $name, @args ) = @_; - return $c->container->get_component_from_sub_container( 'controller', $name, $c, @args) - if( $name ); +# FIXME: should this be a Catalyst::Utils method? + if (!$name) { + my $class = $c->action->class; + + my $prefix = length Catalyst::Utils::class2classprefix($class); + + # MyApp::Controller::Foo becomes Foo + # the + 2 is because of the :: + $name = substr $class, $prefix + 2; + } - return $c->component( $c->action->class ); + return $c->container->get_component_from_sub_container( 'controller', $name, $c, @args); } =head2 $c->model($name)