From: André Walker Date: Wed, 2 May 2012 02:03:55 +0000 (-0300) Subject: ConstructorInjection now depends on the application, not the application_name X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=d24c7cad0d53c5e72dfd163af5862ba4890d58e2 ConstructorInjection now depends on the application, not the application_name --- diff --git a/lib/Catalyst/IOC/ConstructorInjection.pm b/lib/Catalyst/IOC/ConstructorInjection.pm index bed9355..392d2b7 100644 --- a/lib/Catalyst/IOC/ConstructorInjection.pm +++ b/lib/Catalyst/IOC/ConstructorInjection.pm @@ -44,12 +44,7 @@ sub get { 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_name = $self->param('application'); # Stash catalyst_component_name in the config here, so that custom COMPONENT # methods also pass it. diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index 22f29b8..e5609b3 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -41,6 +41,13 @@ has substitutions => ( default => sub { +{} }, ); +has application => ( + is => 'ro', + isa => 'Catalyst|Str', + lazy => 1, + default => sub { shift->application_name }, +); + has application_name => ( is => 'ro', isa => 'Str', @@ -66,6 +73,7 @@ sub BUILD { substitutions file driver + application application_name prefix extensions @@ -189,6 +197,15 @@ sub build_root_service { ); } +sub build_application_service { + my $self = shift; + + return Bread::Board::Literal->new( + name => 'application', + value => $self->application, + ); +} + sub build_application_name_service { my $self = shift; @@ -719,7 +736,7 @@ sub add_component { class => $component, lifecycle => 'Singleton', dependencies => [ - depends_on( '/application_name' ), + depends_on( '/application' ), ], ), );