more comments
[catagits/Catalyst-Runtime.git] / t / lib / TestAppCustomContainer / NoSugarContainer.pm
CommitLineData
88cea23c 1package TestAppCustomContainer::NoSugarContainer;
3ef84846 2use Moose;
88cea23c 3use namespace::autoclean;
4use Catalyst::IOC;
3ef84846 5
6extends 'Catalyst::IOC::Container';
7
8sub BUILD {
9 my $self = shift;
f831deb1 10
b32d8169 11 warn("Add Bar to model");
ced6f9e2 12 $self->get_sub_container('model')->add_service(
13 Catalyst::IOC::ConstructorInjection->new(
14 name => 'Bar',
a0475a83 15 lifecycle => 'Singleton',
16 class => 'TestAppCustomContainer::Model::Bar',
28ec44a3 17 catalyst_component_name => 'TestAppCustomContainer::Model::Bar',
a0475a83 18 dependencies => {
19 application_name => depends_on( '/application_name' ),
b32d8169 20 foo => depends_on('/model/DefaultSetup'),
f831deb1 21 },
22 )
23 );
24
b32d8169 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(
29# name => 'Baz',
30# lifecycle => '+Catalyst::IOC::LifeCycle::Request',
31# dependencies => [
32# Bread::Board::Dependency->new(
33# service_name => 'foo',
34# service_path => 'Foo',
35#
36# # FIXME - same as above
37# service_params => {
38# ctx => +{},
39# accept_context_args => [ +{} ],
40# },
41# ),
42# ],
43# block => sub {
44# TestAppCustomContainer::Model::Baz->new(foo => shift->param('foo'));
45# },
46# )
47# );
f831deb1 48
b32d8169 49# Broken deps!?!
50# $self->get_sub_container('model')->add_service(
51# Catalyst::IOC::BlockInjection->new(
52# name => 'Quux',
53# lifecycle => 'Singleton',
54# dependencies => [
55# depends_on( '/component/model_Quux' ),
56# ],
57# block => sub { shift->param('model_Bar') },
58# )
59# );
f831deb1 60
00f61c9b 61 my $fnar_config = $self->resolve(service => 'config')->{'Model::Fnar'} || {};
f831deb1 62 $self->get_sub_container('component')->add_service(
63 Catalyst::IOC::ConstructorInjection->new(
64 name => 'model_Fnar',
65 lifecycle => 'Singleton',
b463fcad 66 class => 'TestAppCustomContainer::External::Class',
f831deb1 67 dependencies => [
68 depends_on( '/application_name' ),
f831deb1 69 ],
00f61c9b 70 config => $fnar_config,
f831deb1 71 )
72 );
73 $self->get_sub_container('model')->add_service(
74 Catalyst::IOC::BlockInjection->new(
75 name => 'model_Fnar',
76 lifecycle => 'Singleton',
77 dependencies => [
78 depends_on( '/config' ),
79 depends_on( '/component/model_Fnar' ),
80 ],
81 block => sub { shift->param('model_Fnar') },
82 )
83 );
3ef84846 84}
85
88cea23c 86__PACKAGE__->meta->make_immutable;
87
3ef84846 881;