let each test component do one thing. leave depends_on(DefaultSetup) for a while
[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             },
21         )
22     );
23
24     warn("Add RequestLifeCycle to model");
25     $self->get_sub_container('model')->add_service(
26         Catalyst::IOC::ConstructorInjection->new(
27             name         => 'RequestLifeCycle',
28             lifecycle    => '+Catalyst::IOC::LifeCycle::Request',
29             class        => 'TestAppCustomContainer::Model::RequestLifeCycle',
30             catalyst_component_name => 'TestAppCustomContainer::Model::RequestLifeCycle',
31             dependencies => {
32                 application_name => depends_on( '/application_name' ),
33             },
34         )
35     );
36
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
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 #    );
63
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 #    );
87 }
88
89 __PACKAGE__->meta->make_immutable;
90
91 1;