enabling new lifecycle in test + FIXME
[catagits/Catalyst-Runtime.git] / t / lib / TestAppCustomContainer / NoSugarContainer.pm
1 package TestAppCustomContainer::NoSugarContainer;
2 use Moose;
3 use namespace::autoclean;
4 use Catalyst::IOC;
5
6 extends 'Catalyst::IOC::Container';
7
8 sub BUILD {
9     my $self = shift;
10     $self->get_sub_container('component')->add_service(
11         Catalyst::IOC::ConstructorInjection->new(
12             name         => 'model_Baz',
13             class        => 'TestAppCustomContainer::Model::Baz',
14
15 # FIXME - it should simply be Request (or InstancePerRequest, etc)
16 # see Bread/Board/Service.pm line 47
17             lifecycle    => '+Catalyst::IOC::LifeCycle::Request',
18             dependencies => [
19                 depends_on( '/application_name' ),
20                 depends_on( '/config' ),
21                 depends_on( '/model/Foo' ),
22             ],
23         )
24     );
25     $self->get_sub_container('model')->add_service(
26         Catalyst::IOC::BlockInjection->new(
27             name         => 'Baz',
28             dependencies => [
29                 depends_on( '/model/Foo' ),
30                 depends_on( '/component/model_Baz' ),
31             ],
32             block => sub {
33                 my $s        = shift;
34                 my $foo      = $s->param('Foo');
35                 my $instance = $s->param('model_Baz');
36                 return $instance;
37             },
38         )
39     );
40 }
41
42 __PACKAGE__->meta->make_immutable;
43
44 1;