X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FIOC%2FContainer.pm;h=22f29b8a27a1d8f3d35b6b435aafc235c4cb3209;hb=b4e19c62c9c1bef192799f6183104070a8e889bb;hp=6a834ad5fafbd8dca5d9a1eee9bf40594485b08c;hpb=202784d370ccdc0b8c6e4bd6c926e779a9aabb91;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index 6a834ad..22f29b8 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -151,6 +151,44 @@ sub build_component_subcontainer { ); } +sub build_home_service { + my $self = shift; + + return Bread::Board::BlockInjection->new( + lifecycle => 'Singleton', + name => 'home', + block => sub { + my $self = shift; + my $class = $self->param('application_name'); + my $home; + + if ( my $env = Catalyst::Utils::env_value( $class, 'HOME' ) ) { + $home = $env; + } + + $home ||= Catalyst::Utils::home($class); + return $home; + }, + dependencies => [ depends_on('application_name') ], + ); +} + +# FIXME: very ambiguous - maybe root_dir? +sub build_root_service { + my $self = shift; + + return Bread::Board::BlockInjection->new( + lifecycle => 'Singleton', + name => 'root', + block => sub { + my $self = shift; + + return Path::Class::Dir->new( $self->param('home') )->subdir('root'); + }, + dependencies => [ depends_on('home') ], + ); +} + sub build_application_name_service { my $self = shift; @@ -683,8 +721,15 @@ sub add_component { dependencies => [ depends_on( '/application_name' ), ], - ) + ), ); + # XXX - FIXME - We have to explicitly build the service here, + # causing the COMPONENT method to be called early here, as otherwise + # if the component method defines other classes (e.g. the + # ACCEPT_CONTEXT injection Model::DBIC::Schema does) + # then they won't be found by Devel::InnerPackage + # see also t/aggregate/unit_core_component_loading.t + $instance_container->get_service($component_service_name)->get; $accept_context_container->add_service( Catalyst::IOC::BlockInjection->new( @@ -720,6 +765,8 @@ sub expand_component_module { return Devel::InnerPackage::list_packages( $module ); } +__PACKAGE__->meta->make_immutable; + 1; __END__