1Catalyst::Controller(3)User Contributed Perl DocumentatioCnatalyst::Controller(3)
2
3
4
6 Catalyst::Controller - Catalyst Controller base class
7
9 package MyApp::Controller::Search
10 use base qw/Catalyst::Controller/;
11
12 sub foo : Local {
13 my ($self,$c,@args) = @_;
14 ...
15 } # Dispatches to /search/foo
16
18 Controllers are where the actions in the Catalyst framework reside.
19 Each action is represented by a function with an attribute to identify
20 what kind of action it is. See the Catalyst::Dispatcher for more info
21 about how Catalyst dispatches to actions.
22
24 Like any other Catalyst::Component, controllers have a config hash,
25 accessible through $self->config from the controller actions. Some
26 settings are in use by the Catalyst framework:
27
28 namespace
29
30 This specifies the internal namespace the controller should be bound
31 to. By default the controller is bound to the URI version of the con‐
32 troller name. For instance controller 'MyApp::Controller::Foo::Bar'
33 will be bound to 'foo/bar'. The default Root controller is an example
34 of setting namespace to '' (the null string).
35
36 path
37
38 Sets 'path_prefix', as described below.
39
41 $class->new($app, @args)
42
43 Proxies through to NEXT::new and stashes the application instance as
44 $self->_application.
45
46 $self->action_for('name')
47
48 Returns the Catalyst::Action object (if any) for a given method name in
49 this component.
50
51 $self->register_actions($c)
52
53 Finds all applicable actions for this component, creates Cata‐
54 lyst::Action objects (using $self->create_action) for them and regis‐
55 ters them with $c->dispatcher.
56
57 $self->action_namespace($c)
58
59 Returns the private namespace for actions in this component. Defaults
60 to a value from the controller name (for e.g. MyApp::Con‐
61 troller::Foo::Bar becomes "foo/bar") or can be overridden from the
62 "namespace" config key.
63
64 $self->path_prefix($c)
65
66 Returns the default path prefix for :Local, :LocalRegex and relative
67 :Path actions in this component. Defaults to the action_namespace or
68 can be overridden from the "path" config key.
69
70 $self->create_action(%args)
71
72 Called with a hash of data to be use for construction of a new Cata‐
73 lyst::Action (or appropriate sub/alternative class) object.
74
75 Primarily designed for the use of register_actions.
76
77 $self->_application
78
79 $self->_app
80
81 Returns the application instance stored by "new()"
82
84 Sebastian Riedel, "sri@oook.de" Marcus Ramberg "mramberg@cpan.org"
85
87 This program is free software, you can redistribute it and/or modify it
88 under the same terms as Perl itself.
89
90
91
92perl v5.8.8 2007-09-20 Catalyst::Controller(3)