X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FIOC%2FContainer.pm;h=07d7fc572c5c773b4876cdf912e49bed397af226;hb=9084f394cf7b3a451cac0b6732b921b2dd3fad55;hp=45235c9959cec608cc9c7b78bc061dd3d0903f44;hpb=25af999b0a428cfb275f50a936df797217fcec54;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index 45235c9..07d7fc5 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -592,16 +592,16 @@ sub find_component { } sub _find_component_regexp { - my ( $self, $component, @args ) = @_; + my ( $self, $component, $ctx, @args ) = @_; my @result; - my @components = grep { m{$component} } keys %{ $self->get_all_components }; + my @components = grep { m{$component} } keys %{ $self->get_all_components($ctx) }; for (@components) { my ($type, $name) = _get_component_type_name($_); push @result, $self->get_component_from_sub_container( - $type, $name, @args + $type, $name, $ctx, @args ) if $type; } @@ -609,7 +609,7 @@ sub _find_component_regexp { } sub get_all_components { - my $self = shift; + my ($self, $class) = @_; my %components; # FIXME - if we're getting from these containers, we need to either: @@ -619,27 +619,9 @@ sub get_all_components { my $container = $self->get_sub_container($type); for my $component ($container->get_service_list) { - my $comp = $container->resolve( - service => $component - ); - my $comp_name = ref $comp || $comp; # THIS IS WRONG! :) - # Just as it is called Model::Foo - # does not mean it has to be - # an instance of model::foo - # (André's answer) - # t0m, you're absolutely right, I really hadn't thought about it. - # But then, we have a problem: suppose there is a component called - # MyApp::M::Foo, for instance. The service name would be 'Foo', - # and it would be stored in the 'model' sub container. So we have - # $app_name . '::' . uc_first($type) . '::' . $service_name - # that would return MyApp::Model::Foo. It would get really, really - # ugly to check MyApp::M::Foo. So, either we change the hash key, - # or we drop support for ::[CMV]::, or I don't know, maybe you - # have a better solution? :) - # maybe catalyst_component_name? But then we'd have the same - # problem on Catalyst::IOC line 73 - - $components{$comp_name} = $comp; + my $comp_service = $container->get_service($component); + + $components{$comp_service->catalyst_component_name} = $comp_service->get(ctx => $class); } } @@ -681,6 +663,7 @@ sub add_component { $accept_context_container->add_service( Catalyst::IOC::BlockInjection->new( name => $name, + catalyst_component_name => $component, dependencies => [ depends_on( "/component/$component_service_name" ), ],