let each test component do one thing. leave depends_on(DefaultSetup) for a while
[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
a5f37ed6 11 warn("Add SingletonLifeCycle to model");
ced6f9e2 12 $self->get_sub_container('model')->add_service(
13 Catalyst::IOC::ConstructorInjection->new(
04189a0f 14 name => 'SingletonLifeCycle',
a0475a83 15 lifecycle => 'Singleton',
04189a0f 16 class => 'TestAppCustomContainer::Model::SingletonLifeCycle',
17 catalyst_component_name => 'TestAppCustomContainer::Model::SingletonLifeCycle',
a0475a83 18 dependencies => {
19 application_name => depends_on( '/application_name' ),
f831deb1 20 },
21 )
22 );
23
576d8ab8 24 warn("Add RequestLifeCycle to model");
a5f37ed6 25 $self->get_sub_container('model')->add_service(
a5f37ed6 26 Catalyst::IOC::ConstructorInjection->new(
54f4b8d1 27 name => 'RequestLifeCycle',
a5f37ed6 28 lifecycle => '+Catalyst::IOC::LifeCycle::Request',
54f4b8d1 29 class => 'TestAppCustomContainer::Model::RequestLifeCycle',
576d8ab8 30 catalyst_component_name => 'TestAppCustomContainer::Model::RequestLifeCycle',
a5f37ed6 31 dependencies => {
32 application_name => depends_on( '/application_name' ),
a5f37ed6 33 },
34 )
35 );
f831deb1 36
072b618d 37# warn("Add DependsOnDefaultSetup to model");
38# $self->get_sub_container('model')->add_service(
39# Catalyst::IOC::ConstructorInjection->new(
40# name => 'DependsOnDefaultSetup',
41# class => 'TestAppCustomContainer::Model::DependsOnDefaultSetup',
42# catalyst_component_name => 'TestAppCustomContainer::Model::DependsOnDefaultSetup',
43# dependencies => {
44# application_name => depends_on( '/application_name' ),
45# # FIXME - this is what is blowing up everything:
46# # DefaultSetup needs the context. It's not getting it here!
47# foo => depends_on('/model/DefaultSetup'),
48# },
49# )
50# );
51
b32d8169 52# Broken deps!?!
53# $self->get_sub_container('model')->add_service(
54# Catalyst::IOC::BlockInjection->new(
55# name => 'Quux',
56# lifecycle => 'Singleton',
57# dependencies => [
58# depends_on( '/component/model_Quux' ),
59# ],
60# block => sub { shift->param('model_Bar') },
61# )
62# );
f831deb1 63
576d8ab8 64# my $fnar_config = $self->resolve(service => 'config')->{'Model::Fnar'} || {};
65# $self->get_sub_container('component')->add_service(
66# Catalyst::IOC::ConstructorInjection->new(
67# name => 'model_Fnar',
68# lifecycle => 'Singleton',
69# class => 'TestAppCustomContainer::External::Class',
70# dependencies => [
71# depends_on( '/application_name' ),
72# ],
73# config => $fnar_config,
74# )
75# );
76# $self->get_sub_container('model')->add_service(
77# Catalyst::IOC::BlockInjection->new(
78# name => 'model_Fnar',
79# lifecycle => 'Singleton',
80# dependencies => [
81# depends_on( '/config' ),
82# depends_on( '/component/model_Fnar' ),
83# ],
84# block => sub { shift->param('model_Fnar') },
85# )
86# );
3ef84846 87}
88
88cea23c 89__PACKAGE__->meta->make_immutable;
90
3ef84846 911;