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