1Catalyst::Controller::AUcsteironCRoonlter(i3b)uted PerlCDaotcaulmyesntt:a:tCioonntroller::ActionRole(3)
2
3
4

NAME

6       Catalyst::Controller::ActionRole - (DEPRECATED) Apply roles to action
7       instances
8

VERSION

10       version 0.17
11

SYNOPSIS

13           package MyApp::Controller::Foo;
14
15           use Moose;
16           use namespace::autoclean;
17
18           BEGIN { extends 'Catalyst::Controller::ActionRole' }
19
20           sub bar : Local Does('Moo') { ... }
21

DESCRIPTION

23       This module allows one to apply Moose::Roles to the "Catalyst::Action"s
24       for different controller methods.
25
26       For that a "Does" attribute is provided. That attribute takes an
27       argument, that determines the role, which is going to be applied. If
28       that argument is prefixed with "+", it is assumed to be the full name
29       of the role. If it's prefixed with "~", the name of your application
30       followed by "::ActionRole::" is prepended. If it isn't prefixed with
31       "+" or "~", the role name will be searched for in @INC according to the
32       rules for role prefix searching.
33
34       It's possible to apply roles to all actions of a controller without
35       specifying the "Does" keyword in every action definition:
36
37           package MyApp::Controller::Bar
38
39           use Moose;
40           use namespace::autoclean;
41
42           BEGIN { extends 'Catalyst::Controller::ActionRole' }
43
44           __PACKAGE__->config(
45               action_roles => ['Foo', '~Bar'],
46           );
47
48           # Has Catalyst::ActionRole::Foo and MyApp::ActionRole::Bar applied.
49           #
50           # If MyApp::ActionRole::Foo exists and is loadable, it will take
51           # precedence over Catalyst::ActionRole::Foo.
52           #
53           # If MyApp::ActionRole::Bar exists and is loadable, it will be loaded,
54           # but even if it doesn't exist Catalyst::ActionRole::Bar will not be loaded.
55           sub moo : Local { ... }
56
57       Additionally, roles can be applied to selected actions without
58       specifying "Does" using "action" in Catalyst::Controller and configured
59       with "action_args" in Catalyst::Controller:
60
61           package MyApp::Controller::Baz;
62
63           use Moose;
64           use namespace::autoclean;
65
66           BEGIN { extends 'Catalyst::Controller::ActionRole' }
67
68           __PACKAGE__->config(
69               action_roles => [qw( Foo )],
70               action       => {
71                   some_action    => { Does => [qw( ~Bar )] },
72                   another_action => { Does => [qw( +MyActionRole::Baz )] },
73               },
74               action_args  => {
75                   another_action => { customarg => 'arg1' },
76               }
77           );
78
79           # has Catalyst::ActionRole::Foo and MyApp::ActionRole::Bar applied
80           sub some_action : Local { ... }
81
82           # has Catalyst::ActionRole::Foo and MyActionRole::Baz applied
83           # and associated action class would get additional arguments passed
84           sub another_action : Local { ... }
85

ATTRIBUTES

87   _action_role_prefix
88       This class attribute stores an array reference of role prefixes to
89       search for role names in if they aren't prefixed with "+" or "~". It
90       defaults to "[ 'Catalyst::ActionRole::' ]".  See "role prefix
91       searching".
92
93   _action_roles
94       This attribute stores an array reference of role names that will be
95       applied to every action of this controller. It can be set by passing a
96       "action_roles" argument to the constructor. The same expansions as for
97       "Does" will be performed.
98

METHODS

100   gather_action_roles(\%action_args)
101       Gathers the list of roles to apply to an action with the given
102       %action_args.
103

DEPRECATION NOTICE

105       As of version 5.90013, Catalyst has merged this functionality into the
106       core Catalyst::Controller.  You should no longer use it for new
107       development and we recommend switching to the core controller as soon
108       as practical.
109

ROLE PREFIX SEARCHING

111       Roles specified with no prefix are looked up under a set of role
112       prefixes.  The first prefix is always "MyApp::ActionRole::" (with
113       "MyApp" replaced as appropriate for your application); the following
114       prefixes are taken from the "_action_role_prefix" attribute.
115

AUTHOR

117       Florian Ragwitz <rafl@debian.org>
118
120       This software is copyright (c) 2009 by Florian Ragwitz.
121
122       This is free software; you can redistribute it and/or modify it under
123       the same terms as the Perl 5 programming language system itself.
124

CONTRIBUTORS

126       ·   Karen Etheridge <ether@cpan.org>
127
128       ·   Tomas Doran <bobtfish@bobtfish.net>
129
130       ·   Hans Dieter Pearcey <hdp@weftsoar.net>
131
132       ·   Alex J. G. Burzyński <ajgb@ajgb.net>
133
134       ·   Jason Kohles <email@jasonkohles.com>
135
136       ·   William King <william.king@quentustech.com>
137
138       ·   NAKAGAWA Masaki <masaki.nakagawa@gmail.com>
139
140       ·   Joenio Costa <joenio@cpan.org>
141
142       ·   John Napiorkowski <jjnapiork@cpan.org>
143
144
145
146perl v5.28.1                      2015-02-02Catalyst::Controller::ActionRole(3)
Impressum