From: André Walker Date: Tue, 12 Jul 2011 18:33:27 +0000 (-0300) Subject: small adjustments in ->component() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1c1bb322fd27968c04987a1b65c0144a99ba7284;hp=5be6c1d8aa115905e3217fa220c903e950021abc;p=catagits%2FCatalyst-Runtime.git small adjustments in ->component() --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index ad387c0..e6a9f4d 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -695,10 +695,6 @@ sub component { my ( $c, $component, @args ) = @_; if ( $component ) { - # FIXME: I probably shouldn't be doing this - return $c->components->{$component} - if exists $c->components->{$component}; - my ($type, $name) = _get_component_type_name($component); if ($type && $c->container->has_sub_container($type)) { @@ -717,10 +713,16 @@ sub component { my @components = $subcontainer->get_service_list; my @result = grep { m{$component} } @components; - return map { $subcontainer->get_component( $_, $c, @args ) } @result; + return map { $subcontainer->get_component( $_, $c, @args ) } @result + if @result; } } + # FIXME: I probably shouldn't be doing this + # I'm keeping it temporarily for things like $c->comp('MyApp') + return $c->components->{$component} + if exists $c->components->{$component} and !@args; + $c->log->warn("Looking for '$component', but nothing was found."); # I would expect to return an empty list here, but that breaks back-compat