1 package TestAppCustomContainer::NoSugarContainer;
3 use namespace::autoclean;
6 extends 'Catalyst::IOC::Container';
11 warn("Add Bar to model");
12 $self->get_sub_container('model')->add_service(
13 Catalyst::IOC::ConstructorInjection->new(
14 name => 'SingletonLifeCycle',
15 lifecycle => 'Singleton',
16 class => 'TestAppCustomContainer::Model::SingletonLifeCycle',
17 catalyst_component_name => 'TestAppCustomContainer::Model::SingletonLifeCycle',
19 application_name => depends_on( '/application_name' ),
20 foo => depends_on('/model/DefaultSetup'),
25 # $self->get_sub_container('model')->add_service(
26 # # FIXME - i think it should be a ConstructorInjection
27 # # but only BlockInjection gets ctx parameter
28 # Catalyst::IOC::BlockInjection->new(
30 # lifecycle => '+Catalyst::IOC::LifeCycle::Request',
32 # Bread::Board::Dependency->new(
33 # service_name => 'foo',
34 # service_path => 'Foo',
36 # # FIXME - same as above
39 # accept_context_args => [ +{} ],
44 # TestAppCustomContainer::Model::Baz->new(foo => shift->param('foo'));
50 # $self->get_sub_container('model')->add_service(
51 # Catalyst::IOC::BlockInjection->new(
53 # lifecycle => 'Singleton',
55 # depends_on( '/component/model_Quux' ),
57 # block => sub { shift->param('model_Bar') },
61 my $fnar_config = $self->resolve(service => 'config')->{'Model::Fnar'} || {};
62 $self->get_sub_container('component')->add_service(
63 Catalyst::IOC::ConstructorInjection->new(
65 lifecycle => 'Singleton',
66 class => 'TestAppCustomContainer::External::Class',
68 depends_on( '/application_name' ),
70 config => $fnar_config,
73 $self->get_sub_container('model')->add_service(
74 Catalyst::IOC::BlockInjection->new(
76 lifecycle => 'Singleton',
78 depends_on( '/config' ),
79 depends_on( '/component/model_Fnar' ),
81 block => sub { shift->param('model_Fnar') },
86 __PACKAGE__->meta->make_immutable;