Discovered some inconsistency in precedence behavior of chained actions.
[catagits/Catalyst-Runtime.git] / t / lib / ChainedActionsApp / Controller / Root.pm
1 package ChainedActionsApp::Controller::Root;
2 use Moose;
3 use namespace::autoclean;
4
5 BEGIN { extends 'Catalyst::Controller' }
6
7 #
8 # Sets the actions in this controller to be registered with no prefix
9 # so they function identically to actions created in MyApp.pm
10 #
11 __PACKAGE__->config(namespace => '');
12
13 =head1 NAME
14
15 test_chained::Controller::Root - Root Controller for test_chained
16
17 =head1 DESCRIPTION
18
19 [enter your description here]
20
21 =head1 METHODS
22
23 =head2 setup
24
25 This is the C<setup> method that initializes the request. Any matching action
26 will go through this, so it is an application-wide automatically executed
27 action. For more information, see L<Catalyst::DispatchType::Chained>
28
29 =cut
30
31 sub setup : Chained('/') PathPart('') CaptureArgs(0) {
32     my ( $self, $c ) = @_;
33     # Common things here are to check for ACL and setup global contexts
34 }
35
36 sub home : Chained('setup') PathPart('') Args(0) {
37     my($self,$c) = @_;
38     $c->response->body( "Application Home Page" );
39 }
40
41 =head2 home_base
42
43      Args:
44        project_id
45        project_title
46
47 =cut
48
49 sub home_base : Chained('setup') PathPart('') CaptureArgs(2) {
50     my($self,$c,$proj_id,$title) = @_;
51     $c->stash->{project_id}=$proj_id;
52 }
53
54 sub hpages : Chained('home_base') PathPart('') Args(0) {
55     my($self,$c) = @_;
56     $c->response->body( "List project " . $c->stash->{project_id} . " pages");
57 }
58
59 sub hpage : Chained('home_base') PathPart('') Args(2) {
60     my($self,$c,$page_id, $pagetitle) = @_;
61     $c->response->body( "This is $pagetitle page of " . $c->stash->{project_id} . " project" );
62 }
63
64 sub no_account : Chained('setup') PathPart('account') Args(0) {
65     my($self,$c) = @_;
66     $c->response->body( "New account o login" );
67 }
68
69 sub account_base : Chained('setup') PathPart('account') CaptureArgs(1) {
70     my($self,$c,$acc_id) = @_;
71     $c->stash({account_id=>$acc_id});
72 }
73
74 sub account : Chained('account_base') PathPart('') Args(0) {
75     my($self,$c,$acc) = @_;
76     $c->response->body( "This is account " . $c->stash->{account_id} );
77 }
78
79 =head2 default
80
81 Standard 404 error page
82
83 =cut
84
85 sub default : Chained('setup') PathPart('') Args() {
86     my ( $self, $c ) = @_;
87     $c->response->body( 'Page not found' );
88     $c->response->status(404);
89 }
90
91 =head2 end
92
93 Attempt to render a view, if needed.
94
95 =cut
96
97 sub end : ActionClass('RenderView') {}
98
99 =head1 AUTHOR
100
101 Ferruccio Zamuner
102
103 =head1 LICENSE
104
105 This library is free software. You can redistribute it and/or modify
106 it under the same terms as Perl itself.
107
108 =cut
109
110 __PACKAGE__->meta->make_immutable;
111
112 1;