Commit | Line | Data |
2402ef14 |
1 | package Catalyst::IOC::LifeCycle::Request; |
2 | use Moose::Role; |
3 | use namespace::autoclean; |
da87ad6a |
4 | with 'Bread::Board::LifeCycle'; |
2402ef14 |
5 | |
1a6941f5 |
6 | around get => sub { |
7 | my $orig = shift; |
8 | my $self = shift; |
9 | |
da87ad6a |
10 | my $instance = $self->$orig(@_); |
11 | |
12 | # FIXME - |
13 | # during setup in Catalyst.pm: |
14 | # - $class->setup_actions (line 3025) |
15 | # - $c->dispatcher->setup_actions (line 2271) |
16 | # - $c->components in Catalyst/Dispatcher.pm line 604 |
17 | # which boils down to line 616 in Catalyst/IOC/Container.pm |
18 | # resolving the component _without_ the 'context' parameter. |
19 | # Should it get the context parameter? Should all calls to a |
20 | # ConstructorInjection service pass that parameter? |
21 | my $ctx = $self->param('ctx') |
22 | or return $instance; |
23 | |
1a6941f5 |
24 | my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name; |
da87ad6a |
25 | return $ctx->stash->{$stash_key} ||= $instance; |
1a6941f5 |
26 | }; |
27 | |
2402ef14 |
28 | 1; |
64e06b7d |
29 | |
30 | __END__ |
31 | |
32 | =pod |
33 | |
34 | =head1 NAME |
35 | |
36 | Catalyst::IOC::LifeCycle::Request - Components that last for one request |
37 | |
38 | =head1 SYNOPSIS |
39 | |
40 | =head1 DESCRIPTION |
41 | |
42 | =head1 METHODS |
43 | |
44 | =head1 AUTHORS |
45 | |
46 | Catalyst Contributors, see Catalyst.pm |
47 | |
48 | =head1 COPYRIGHT |
49 | |
50 | This library is free software. You can redistribute it and/or modify it under |
51 | the same terms as Perl itself. |
52 | |
53 | =cut |