1CatalystX::InjectComponUesnetr(3C)ontributed Perl DocumeCnattaatliyosntX::InjectComponent(3)
2
3
4

NAME

6       CatalystX::InjectComponent - Inject components into your Catalyst
7       application
8

VERSION

10       version 0.025
11

SYNOPSIS

13           package My::App;
14
15           use Catalyst::Runtime '5.80';
16
17           use Moose;
18           BEGIN { extends qw/Catalyst/ }
19
20           ...
21
22           after 'setup_components' => sub {
23               my $class = shift;
24               CatalystX::InjectComponent->inject( into => $class, component => 'MyModel' );
25               if ( $class->config->{ ... ) {
26                   CatalystX::InjectComponent->inject( into => $class, component => 'MyRootV2', as => 'Controller::Root' );
27               }
28               else {
29                   CatalystX::InjectComponent->inject( into => $class, component => 'MyRootV1', as => 'Root' ); # Controller:: will be automatically prefixed
30               }
31           };
32

DESCRIPTION

34       CatalystX::InjectComponent will inject Controller, Model, and View
35       components into your Catalyst application at setup (run)time. It does
36       this by creating a new package on-the-fly, having that package extend
37       the given component, and then having Catalyst setup the new component
38       (via "->setup_component")
39

So, how do I use this thing?

41       You should inject your components when appropriate, typically after
42       "setup_compenents" runs
43
44       If you're using the Moose version of Catalyst, then you can use the
45       following technique:
46
47           use Moose;
48           BEGIN { extends qw/Catalyst/ }
49
50           after 'setup_components' => sub {
51               my $class = shift;
52
53               CatalystX::InjectComponent->inject( into => $class, ... )
54           };
55

METHODS

57   CatalystX::InjectComponent->inject( ... )
58           into        The Catalyst package to inject into (e.g. My::App)
59           component   The component package to inject
60           as          An optional moniker to use as the package name for the derived component
61
62       For example:
63
64           ->inject( into => My::App, component => Other::App::Controller::Apple )
65
66               The above will create 'My::App::Controller::Other::App::Controller::Apple'
67
68           ->inject( into => My::App, component => Other::App::Controller::Apple, as => Apple )
69
70               The above will create 'My::App::Controller::Apple'
71

ACKNOWLEDGEMENTS

73       Inspired by Catalyst::Plugin::AutoCRUD
74

AUTHOR

76       Robert Krimen <robertkrimen@gmail.com>
77
79       This software is copyright (c) 2012 by Robert Krimen.
80
81       This is free software; you can redistribute it and/or modify it under
82       the same terms as the Perl 5 programming language system itself.
83
84
85
86perl v5.38.0                      2023-07-20     CatalystX::InjectComponent(3)
Impressum