Commit | Line | Data |
b7da37bd |
1 | package Catalyst::IOC::ConstructorInjection; |
2 | use Moose; |
3 | extends 'Bread::Board::ConstructorInjection'; |
4 | |
bf142143 |
5 | with '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 |
11 | sub 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 | |
30 | no Moose; 1; |
31 | |
32 | __END__ |
33 | |
34 | =pod |
35 | |
36 | =head1 NAME |
37 | |
1ab07ed4 |
38 | Catalyst::IOC::ConstructorInjection |
39 | |
40 | =head1 SYNOPSIS |
41 | |
42 | =head1 DESCRIPTION |
b7da37bd |
43 | |
44 | =head1 AUTHORS |
45 | |
46 | Catalyst Contributors, see Catalyst.pm |
47 | |
48 | =head1 COPYRIGHT |
49 | |
50 | This library is free software. You can redistribute it and/or modify it under |
51 | the same terms as Perl itself. |
52 | |
53 | =cut |