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