14f5f3466c4b246fc6d612f50e8240618b4b35ca
[catagits/Catalyst-Runtime.git] / t / lib / TestAppCustomContainer / NoSugarContainer.pm
1 package TestAppCustomContainer::NoSugarContainer;
2 use Moose;
3 use namespace::autoclean;
4 use Catalyst::IOC;
5
6 extends 'Catalyst::IOC::Container';
7
8 sub BUILD {
9     my $self = shift;
10
11     warn("Add SingletonLifeCycle 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',
18             dependencies     => {
19                 application_name => depends_on( '/application_name' ),
20                 foo => depends_on('/model/DefaultSetup'),
21             },
22         )
23     );
24
25     warn("Add RequestLifeCycle to model");
26     $self->get_sub_container('model')->add_service(
27         Catalyst::IOC::ConstructorInjection->new(
28             name         => 'RequestLifeCycle',
29             lifecycle    => '+Catalyst::IOC::LifeCycle::Request',
30             class        => 'TestAppCustomContainer::Model::RequestLifeCycle',
31             catalyst_component_name => 'TestAppCustomContainer::Model::RequestLifeCycle',
32             dependencies => {
33                 application_name => depends_on( '/application_name' ),
34                 # FIXME - this is what is blowing up everything:
35                 # DefaultSetup needs the context. It's not getting it here!
36                 foo => depends_on('/model/DefaultSetup'),
37             },
38         )
39     );
40
41 # Broken deps!?!
42 #    $self->get_sub_container('model')->add_service(
43 #        Catalyst::IOC::BlockInjection->new(
44 #            name         => 'Quux',
45 #            lifecycle    => 'Singleton',
46 #            dependencies => [
47 #                depends_on( '/component/model_Quux' ),
48 #            ],
49 #            block => sub { shift->param('model_Bar') },
50 #        )
51 #    );
52
53 #    my $fnar_config = $self->resolve(service => 'config')->{'Model::Fnar'} || {};
54 #    $self->get_sub_container('component')->add_service(
55 #        Catalyst::IOC::ConstructorInjection->new(
56 #            name         => 'model_Fnar',
57 #            lifecycle    => 'Singleton',
58 #            class        => 'TestAppCustomContainer::External::Class',
59 #            dependencies => [
60 #                depends_on( '/application_name' ),
61 #            ],
62 #            config => $fnar_config,
63 #        )
64 #    );
65 #    $self->get_sub_container('model')->add_service(
66 #        Catalyst::IOC::BlockInjection->new(
67 #            name         => 'model_Fnar',
68 #            lifecycle    => 'Singleton',
69 #            dependencies => [
70 #                depends_on( '/config' ),
71 #                depends_on( '/component/model_Fnar' ),
72 #            ],
73 #            block => sub { shift->param('model_Fnar') },
74 #        )
75 #    );
76 }
77
78 __PACKAGE__->meta->make_immutable;
79
80 1;