1 package Catalyst::IOC::ConstructorInjection;
3 use Catalyst::Utils ();
4 extends 'Bread::Board::ConstructorInjection';
6 with 'Bread::Board::Service::WithClass',
7 'Bread::Board::Service::WithDependencies',
8 'Bread::Board::Service::WithParameters',
9 'Catalyst::IOC::Service::WithCOMPONENT';
17 sub _build_config_key {
18 Catalyst::Utils::class2classsuffix( shift->class );
21 # FIXME - how much of this should move to ::WithCOMPONENT?
25 my $constructor = $self->constructor_name;
26 my $component = $self->class;
27 my $params = $self->params;
28 my $config = $params->{config}->{ $self->config_key } || {};
29 # FIXME - Is depending on the application name to pass into constructors here a good idea?
30 # This makes app/ctx split harder I think.. Need to think more here, but I think
31 # we want to pass the application in as a parameter when building the service
32 # rather than depending on the app name, so that later, when the app becomes an instance
33 # then it'll get passed in, and components can stash themselves 'per app instance'
34 my $app_name = $params->{application_name};
36 # Stash catalyst_component_name in the config here, so that custom COMPONENT
37 # methods also pass it. local to avoid pointlessly shitting in config
38 # for the debug screen, as $component is already the key name.
39 local $config->{catalyst_component_name} = $component;
41 return $component->$constructor( $app_name, $config );
44 __PACKAGE__->meta->make_immutable;
54 Catalyst::IOC::ConstructorInjection
62 Catalyst Contributors, see Catalyst.pm
66 This library is free software. You can redistribute it and/or modify it under
67 the same terms as Perl itself.