1 package TestAppCustomContainer::NoSugarContainer;
3 use namespace::autoclean;
6 extends 'Catalyst::IOC::Container';
11 $self->get_sub_container('component')->add_service(
12 Catalyst::IOC::ConstructorInjection->new(
14 lifecycle => 'Singleton',
15 class => 'TestAppCustomContainer::Model::Bar',
17 depends_on( '/application_name' ),
18 depends_on( '/config' ),
19 depends_on( '/model/Foo' ),
23 $self->get_sub_container('model')->add_service(
24 Catalyst::IOC::BlockInjection->new(
26 lifecycle => 'Singleton',
28 Bread::Board::Dependency->new(
29 service_path => 'Foo',
31 # FIXME - obviously this is a mistake
32 # what to do with ctx here?
33 # I have no way to get $s here, do I?
36 accept_context_args => [ +{} ],
39 depends_on( '/component/model_Bar' ),
44 my $foo = $s->param('Foo');
47 return $s->param('model_Bar');
52 $self->get_sub_container('component')->add_service(
53 Catalyst::IOC::ConstructorInjection->new(
55 class => 'TestAppCustomContainer::Model::Baz',
56 lifecycle => 'Singleton',
58 # while it doesn't fully work
59 #lifecycle => '+Catalyst::IOC::LifeCycle::Request',
61 depends_on( '/application_name' ),
62 depends_on( '/config' ),
63 depends_on( '/model/Foo' ),
67 $self->get_sub_container('model')->add_service(
68 Catalyst::IOC::BlockInjection->new(
71 Bread::Board::Dependency->new(
72 service_path => 'Foo',
74 # FIXME - same as above
77 accept_context_args => [ +{} ],
80 depends_on( '/component/model_Baz' ),
85 my $foo = $s->param('Foo');
88 return $s->param('model_Baz');
93 $self->get_sub_container('model')->add_service(
94 Catalyst::IOC::BlockInjection->new(
96 lifecycle => 'Singleton',
98 depends_on( '/component/model_Quux' ),
100 block => sub { shift->param('model_Bar') },
104 $self->get_sub_container('component')->add_service(
105 Catalyst::IOC::ConstructorInjection->new(
106 name => 'model_Fnar',
107 lifecycle => 'Singleton',
108 class => 'TestAppCustomContainer::External::Class',
110 depends_on( '/application_name' ),
111 depends_on( '/config' ),
115 $self->get_sub_container('model')->add_service(
116 Catalyst::IOC::BlockInjection->new(
117 name => 'model_Fnar',
118 lifecycle => 'Singleton',
120 depends_on( '/config' ),
121 depends_on( '/component/model_Fnar' ),
123 block => sub { shift->param('model_Fnar') },
128 __PACKAGE__->meta->make_immutable;