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;h=cb82f697f33ec7e45bfae1e95c63726cc00adefc;hp=a5c4492eb5a19fea752dbcbca511083e2e68aba2;hb=1a5adaee236dda2152a9d0fb1ca27d08f3f92777;hpb=344858a720ae4deadd0bd67569a8880984690d28 diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index a5c4492..cb82f69 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -60,7 +60,7 @@ sub BUILD { substitutions file driver - application_name + catalyst_application prefix extensions path @@ -74,6 +74,8 @@ sub BUILD { config_local_suffix config_path locate_components + home + root_dir /; my $config = $self->resolve( service => 'config' ); @@ -152,18 +154,23 @@ sub build_home_service { lifecycle => 'Singleton', name => 'home', block => sub { - my $self = shift; - my $class = $self->param('application_name'); - my $home; + my $self = shift; + my $class = $self->param('catalyst_application'); if ( my $env = Catalyst::Utils::env_value( $class, 'HOME' ) ) { - $home = $env; + return $env; + } + + if ( my $home = $self->param('home_flag') ) { + return $home; } - $home ||= Catalyst::Utils::home($class); - return $home; + return Catalyst::Utils::home($class); + }, + parameters => { + home_flag => { is => 'ro', isa => 'Str|Undef', required => 0 } }, - dependencies => [ depends_on('application_name') ], + dependencies => [ depends_on('catalyst_application') ], ); } @@ -182,10 +189,10 @@ sub build_root_dir_service { ); } -sub build_application_name_service { +sub build_catalyst_application_service { my $self = shift; - return Bread::Board::Literal->new( name => 'application_name', value => $self->name ); + return Bread::Board::Literal->new( name => 'catalyst_application', value => $self->name ); } sub build_driver_service { @@ -225,9 +232,9 @@ sub build_prefix_service { lifecycle => 'Singleton', name => 'prefix', block => sub { - return Catalyst::Utils::appprefix( shift->param('application_name') ); + return Catalyst::Utils::appprefix( shift->param('catalyst_application') ); }, - dependencies => [ depends_on('application_name') ], + dependencies => [ depends_on('catalyst_application') ], ); } @@ -240,11 +247,11 @@ sub build_path_service { block => sub { my $s = shift; - return Catalyst::Utils::env_value( $s->param('application_name'), 'CONFIG' ) + return Catalyst::Utils::env_value( $s->param('catalyst_application'), 'CONFIG' ) || $s->param('file') - || $s->param('application_name')->path_to( $s->param('prefix') ); + || $s->param('catalyst_application')->path_to( $s->param('prefix') ); }, - dependencies => [ depends_on('file'), depends_on('application_name'), depends_on('prefix') ], + dependencies => [ depends_on('file'), depends_on('catalyst_application'), depends_on('prefix') ], ); } @@ -260,13 +267,13 @@ sub build_config_service { my $v = Data::Visitor::Callback->new( plain_value => sub { return unless defined $_; - return $self->_config_substitutions( $s->param('application_name'), $s->param('substitutions'), $_ ); + return $self->_config_substitutions( $s->param('catalyst_application'), $s->param('substitutions'), $_ ); } ); $v->visit( $s->param('raw_config') ); }, - dependencies => [ depends_on('application_name'), depends_on('raw_config'), depends_on('substitutions') ], + dependencies => [ depends_on('catalyst_application'), depends_on('raw_config'), depends_on('substitutions') ], ); } @@ -358,7 +365,7 @@ sub build_class_config_service { name => 'class_config', block => sub { my $s = shift; - my $app = $s->param('application_name'); + my $app = $s->param('catalyst_application'); # Container might be called outside Catalyst context return {} unless Class::MOP::is_class_loaded($app); @@ -366,7 +373,7 @@ sub build_class_config_service { # config might not have been defined return $app->config || {}; }, - dependencies => [ depends_on('application_name') ], + dependencies => [ depends_on('catalyst_application') ], ); } @@ -443,11 +450,11 @@ sub build_config_local_suffix_service { name => 'config_local_suffix', block => sub { my $s = shift; - my $suffix = Catalyst::Utils::env_value( $s->param('application_name'), 'CONFIG_LOCAL_SUFFIX' ) || $self->config_local_suffix; + my $suffix = Catalyst::Utils::env_value( $s->param('catalyst_application'), 'CONFIG_LOCAL_SUFFIX' ) || $self->config_local_suffix; return $suffix; }, - dependencies => [ depends_on('application_name') ], + dependencies => [ depends_on('catalyst_application') ], ); } @@ -459,7 +466,7 @@ sub build_locate_components_service { name => 'locate_components', block => sub { my $s = shift; - my $class = $s->param('application_name'); + my $class = $s->param('catalyst_application'); my $config = $s->param('config')->{ setup_components }; Catalyst::Exception->throw( @@ -477,13 +484,13 @@ sub build_locate_components_service { return [ $locator->plugins ]; }, - dependencies => [ depends_on('application_name'), depends_on('config') ], + dependencies => [ depends_on('catalyst_application'), depends_on('config') ], ); } sub setup_components { my $self = shift; - my $class = $self->resolve( service => 'application_name' ); + my $class = $self->resolve( service => 'catalyst_application' ); my @comps = @{ $self->resolve( service => 'locate_components' ) }; my %comps = map { $_ => 1 } @comps; my $deprecatedcatalyst_component_names = 0; @@ -712,7 +719,7 @@ sub add_component { class => $component, lifecycle => 'Singleton', dependencies => [ - depends_on( '/application_name' ), + depends_on( '/catalyst_application' ), ], ), ); @@ -801,10 +808,21 @@ Same as L, but for controllers. =head1 Methods for Building Services -=head2 build_application_name_service +=head2 build_catalyst_application_service Name of the application (such as MyApp). +=head2 build_home_service + +The application home directory. All the files (including classes, scripts, etc) +created for this application are in this directory, or in a sub-directory below +this one. + +=head2 build_root_dir_service + +Inside the application home (as explained in L), there is +a root directory. This is where all templates and static files are. + =head2 build_driver_service Config options passed directly to the driver being used.