X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FIOC%2FContainer.pm;fp=lib%2FCatalyst%2FIOC%2FContainer.pm;h=8a49438703b648f1ed6cb8ced5a1e2014118bd57;hp=3ad90a2e76aad8de064d874765505e43e9b1563b;hb=dcc2a475181033f04a873c85a370842277de44f1;hpb=666d15c12b89ca3b35625e59110ef2eddf7cabf0 diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index 3ad90a2..8a49438 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -710,6 +710,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;