ConstructorInjection doesn't have accept_context_args parameter
[catagits/Catalyst-Runtime.git] / lib / Catalyst / IOC / ConstructorInjection.pm
CommitLineData
b7da37bd 1package Catalyst::IOC::ConstructorInjection;
2use Moose;
9e6091e2 3use Catalyst::Utils ();
b7da37bd 4extends 'Bread::Board::ConstructorInjection';
5
bf142143 6with 'Bread::Board::Service::WithClass',
7 'Bread::Board::Service::WithDependencies',
104155f6 8 'Bread::Board::Service::WithParameters',
ff0e9735 9 'Catalyst::IOC::Service::WithCOMPONENT';
b7da37bd 10
9e6091e2 11has config_key => (
12 is => 'ro',
13 isa => 'Str',
14 lazy_build => 1,
15);
16
17sub _build_config_key {
18 Catalyst::Utils::class2classsuffix( shift->class );
19}
20
637cebbe 21# FIXME - how much of this should move to ::WithCOMPONENT?
b7da37bd 22sub get {
23 my $self = shift;
24
25 my $constructor = $self->constructor_name;
b7da37bd 26 my $component = $self->class;
bf142143 27 my $params = $self->params;
9e6091e2 28 my $config = $params->{config}->{ $self->config_key } || {};
bf142143 29 my $app_name = $params->{application_name};
b7da37bd 30
b7da37bd 31 # Stash catalyst_component_name in the config here, so that custom COMPONENT
32 # methods also pass it. local to avoid pointlessly shitting in config
33 # for the debug screen, as $component is already the key name.
bf142143 34 local $config->{catalyst_component_name} = $component;
b7da37bd 35
637cebbe 36 return $component->$constructor( $app_name, $config );
b7da37bd 37}
38
39__PACKAGE__->meta->make_immutable;
40
41no Moose; 1;
42
43__END__
44
45=pod
46
47=head1 NAME
48
1ab07ed4 49Catalyst::IOC::ConstructorInjection
50
51=head1 SYNOPSIS
52
53=head1 DESCRIPTION
b7da37bd 54
55=head1 AUTHORS
56
57Catalyst Contributors, see Catalyst.pm
58
59=head1 COPYRIGHT
60
61This library is free software. You can redistribute it and/or modify it under
62the same terms as Perl itself.
63
64=cut