X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FIOC%2FContainer.pm;h=0832f633975b841c2998b29bea049918c20c2cea;hb=5a6043d01caf0a06c1dbcb9a354424f080a676a0;hp=3ad90a2e76aad8de064d874765505e43e9b1563b;hpb=e75fd3e49d0b99efeabadae124329b671e4c8300;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index 3ad90a2..0832f63 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -682,7 +682,8 @@ sub _find_component_regexp { # will use is precisely $type, not 'component'. So for now, I'm returning both # services, to decide later what to do. sub get_all_component_services { - my ($self, $class) = @_; + my $self = shift; + my %components; my $components_container = $self->get_sub_container('component'); @@ -710,6 +711,34 @@ sub get_all_component_services { return lock_hash %components; } +sub get_all_singleton_lifecycle_components { + my $self = shift; + + my %components; + my $components_container = $self->get_sub_container('component'); + + foreach my $type (qw/model view controller /) { + my $container = $self->get_sub_container($type); + + for my $component ($container->get_service_list) { + my $comp_service = $container->get_service($component); + + my $key = $comp_service->catalyst_component_name; + my $lifecycle = $comp_service->lifecycle; + my $comp_name = "${type}_${component}"; + + if (defined $lifecycle && $lifecycle eq 'Singleton') { + $components{$key} = $comp_service->get; + } + elsif ($components_container->has_service($comp_name)) { + $components{$key} = $components_container->get_service($comp_name)->get; + } + } + } + + return lock_hash %components; +} + sub get_all_components { my ($self, $class) = @_; my %components;