Lets stop shitting everywhere
[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 Bar to model");
12     $self->get_sub_container('model')->add_service(
13         Catalyst::IOC::ConstructorInjection->new(
14             name             => 'Bar',
15             lifecycle        => 'Singleton',
16             class            => 'TestAppCustomContainer::Model::Bar',
17             dependencies     => {
18                 application_name => depends_on( '/application_name' ),
19                 config => depends_on( '/config' ),
20                 foo => depends_on('/model/DefaultSetup'),
21             },
22         )
23     );
24
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 #    );
48
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 #    );
60
61     $self->get_sub_container('component')->add_service(
62         Catalyst::IOC::ConstructorInjection->new(
63             name         => 'model_Fnar',
64             lifecycle    => 'Singleton',
65             class        => 'TestAppCustomContainer::External::Class',
66             dependencies => [
67                 depends_on( '/application_name' ),
68                 depends_on( '/config' ),
69             ],
70         )
71     );
72     $self->get_sub_container('model')->add_service(
73         Catalyst::IOC::BlockInjection->new(
74             name         => 'model_Fnar',
75             lifecycle    => 'Singleton',
76             dependencies => [
77                 depends_on( '/config' ),
78                 depends_on( '/component/model_Fnar' ),
79             ],
80             block => sub { shift->param('model_Fnar') },
81         )
82     );
83 }
84
85 __PACKAGE__->meta->make_immutable;
86
87 1;