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)