X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FIOC%2FConstructorInjection.pm;h=dce5deff5fe0083d5db9b0f5990eb2476b85f3ce;hb=96c9f5d4c9cebf815970a5ea94b90ad693ebaa93;hp=ba05b6ab4a81c1d9cddcc5c6635f4ebd55a21f9c;hpb=28ec44a3e0a1c1bf04d6479691d2b8925e4f9ed5;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/IOC/ConstructorInjection.pm b/lib/Catalyst/IOC/ConstructorInjection.pm index ba05b6a..dce5def 100644 --- a/lib/Catalyst/IOC/ConstructorInjection.pm +++ b/lib/Catalyst/IOC/ConstructorInjection.pm @@ -8,8 +8,11 @@ extends 'Bread::Board::ConstructorInjection'; sub BUILD { my $self = shift; - $self->add_dependency(__catalyst_config => Bread::Board::Dependency->new(service_path => '/config')); - warn("Added dependency for config in " . $self->class); + $self->add_dependency( + __catalyst_config => Bread::Board::Dependency->new( + service_path => '/config' + ) + ); } has catalyst_component_name => ( @@ -27,8 +30,6 @@ has config => ( around resolve_dependencies => sub { my ($orig, $self, @args) = @_; my %deps = $self->$orig(@args); - use Data::Dumper; - warn("$self Resolve deps" . Data::Dumper::Dumper(\%deps)); my $app_config = delete $deps{__catalyst_config}; my $conf_key = Catalyst::Utils::class2classsuffix($self->catalyst_component_name); $self->_set_config($app_config->{$conf_key} || {}); @@ -37,24 +38,16 @@ around resolve_dependencies => sub { sub get { my $self = shift; - warn("In get $self"); my $component = $self->class; my $params = $self->params; - my %config = (%{ $self->config }, %{ $params }); - warn(Data::Dumper::Dumper(\%config)); + my %config = (%{ $self->config || {} }, %{ $params }); $self->_clear_config; - # FIXME - Is depending on the application name to pass into constructors here a good idea? - # This makes app/ctx split harder I think.. Need to think more here, but I think - # we want to pass the application in as a parameter when building the service - # rather than depending on the app name, so that later, when the app becomes an instance - # then it'll get passed in, and components can stash themselves 'per app instance' - my $app_name = $self->param('application_name'); + my $app = $self->param('catalyst_application'); # Stash catalyst_component_name in the config here, so that custom COMPONENT - # methods also pass it. local to avoid pointlessly shitting in config - # for the debug screen, as $component is already the key name. + # methods also pass it. $config{catalyst_component_name} = $self->catalyst_component_name; unless ( $component->can( 'COMPONENT' ) ) { @@ -64,7 +57,7 @@ sub get { my $instance; try { - $instance = $component->COMPONENT( $app_name, \%config ); + $instance = $component->COMPONENT( $app, \%config ); } catch { Catalyst::Exception->throw(