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 gives the constructor the wrong
14 Bread::Board::ConstructorInjection->new(
16 lifecycle => 'Singleton',
17 class => 'TestAppCustomContainer::Model::Bar',
18 constructor_name => 'new',
20 application_name => depends_on( '/application_name' ),
21 config => depends_on( '/config' ),
22 foo => Bread::Board::Dependency->new(
23 service_name => 'foo',
24 service_path => '/model/Foo',
26 # FIXME - obviously this is a mistake
27 # what to do with ctx here?
28 # I have no way to get $s here, do I?
31 accept_context_args => [ +{} ],
37 $self->get_sub_container('model')->add_service(
38 Catalyst::IOC::BlockInjection->new(
40 lifecycle => 'Singleton',
42 depends_on( '/component/model_Bar' ),
45 shift->param('model_Bar');
50 # FIXME - this is to avoid the default service to be added
51 # if that happened, the app would die
52 $self->get_sub_container('component')->add_service(
53 service model_Baz => 'TestAppCustomContainer::Model::Baz',
55 $self->get_sub_container('model')->add_service(
56 # FIXME - i think it should be a ConstructorInjection
57 # but only BlockInjection gets ctx parameter
58 Catalyst::IOC::BlockInjection->new(
60 lifecycle => '+Catalyst::IOC::LifeCycle::Request',
62 Bread::Board::Dependency->new(
63 service_name => 'foo',
64 service_path => 'Foo',
66 # FIXME - same as above
69 accept_context_args => [ +{} ],
74 TestAppCustomContainer::Model::Baz->new(foo => shift->param('foo'));
79 $self->get_sub_container('model')->add_service(
80 Catalyst::IOC::BlockInjection->new(
82 lifecycle => 'Singleton',
84 depends_on( '/component/model_Quux' ),
86 block => sub { shift->param('model_Bar') },
90 $self->get_sub_container('component')->add_service(
91 Catalyst::IOC::ConstructorInjection->new(
93 lifecycle => 'Singleton',
94 class => 'TestAppCustomContainer::External::Class',
96 depends_on( '/application_name' ),
97 depends_on( '/config' ),
101 $self->get_sub_container('model')->add_service(
102 Catalyst::IOC::BlockInjection->new(
103 name => 'model_Fnar',
104 lifecycle => 'Singleton',
106 depends_on( '/config' ),
107 depends_on( '/component/model_Fnar' ),
109 block => sub { shift->param('model_Fnar') },
114 __PACKAGE__->meta->make_immutable;