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(
27 Bread::Board::Dependency->new(
28 service_path => 'Foo',
30 # FIXME - obviously this is a mistake
31 # what to do with ctx here?
32 # I have no way to get $s here, do I?
35 accept_context_args => [ +{} ],
38 depends_on( '/component/model_Bar' ),
43 my $foo = $s->param('Foo');
46 return $s->param('model_Bar');
51 $self->get_sub_container('component')->add_service(
52 Catalyst::IOC::ConstructorInjection->new(
54 class => 'TestAppCustomContainer::Model::Baz',
55 lifecycle => 'Singleton',
57 # while it doesn't fully work
58 #lifecycle => '+Catalyst::IOC::LifeCycle::Request',
60 depends_on( '/application_name' ),
61 depends_on( '/config' ),
62 depends_on( 'model_Foo' ),
66 $self->get_sub_container('model')->add_service(
67 Catalyst::IOC::BlockInjection->new(
70 Bread::Board::Dependency->new(
71 service_path => 'Foo',
73 # FIXME - same as above
76 accept_context_args => [ +{} ],
79 depends_on( '/component/model_Baz' ),
84 my $foo = $s->param('Foo');
87 return $s->param('model_Baz');
92 $self->get_sub_container('model')->add_service(
93 Catalyst::IOC::BlockInjection->new(
95 lifecycle => 'Singleton',
97 depends_on( '/component/model_Quux' ),
99 block => sub { shift->param('model_Bar') },
103 $self->get_sub_container('component')->add_service(
104 Catalyst::IOC::ConstructorInjection->new(
105 name => 'model_Fnar',
106 lifecycle => 'Singleton',
107 class => 'TestAppCustomContainer::External::Class',
109 depends_on( '/application_name' ),
110 depends_on( '/config' ),
114 $self->get_sub_container('model')->add_service(
115 Catalyst::IOC::BlockInjection->new(
116 name => 'model_Fnar',
117 lifecycle => 'Singleton',
119 depends_on( '/config' ),
120 depends_on( '/component/model_Fnar' ),
122 block => sub { shift->param('model_Fnar') },
127 __PACKAGE__->meta->make_immutable;