Merge branch 'master' into psgi
[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 sub setup : Chained('/') PathPart('') CaptureArgs(0) {
14     my ( $self, $c ) = @_;
15     # Common things here are to check for ACL and setup global contexts
16 }
17
18 sub home : Chained('setup') PathPart('') Args(0) {
19     my($self,$c) = @_;
20     $c->response->body( "Application Home Page" );
21 }
22
23 sub home_base : Chained('setup') PathPart('') CaptureArgs(2) {
24     my($self,$c,$proj_id,$title) = @_;
25     $c->stash({project_id=>$proj_id, project_title=>$title});
26 }
27
28 sub hpages : Chained('home_base') PathPart('') Args(0) {
29     my($self,$c) = @_;
30     $c->response->body( "List project " . $c->stash->{project_title} . " pages");
31 }
32
33 sub hpage : Chained('home_base') PathPart('') Args(2) {
34     my($self,$c,$page_id, $pagetitle) = @_;
35     $c->response->body( "This is $pagetitle page of " . $c->stash->{project_title} . " project" );
36 }
37
38 sub no_account : Chained('setup') PathPart('account') Args(0) {
39     my($self,$c) = @_;
40     $c->response->body( "New account o login" );
41 }
42
43 sub account_base : Chained('setup') PathPart('account') CaptureArgs(1) {
44     my($self,$c,$acc_id) = @_;
45     $c->stash({account_id=>$acc_id});
46 }
47
48 sub account : Chained('account_base') PathPart('') Args(0) {
49     my($self,$c,$acc) = @_;
50     $c->response->body( "This is account " . $c->stash->{account_id} );
51 }
52
53 sub default : Chained('setup') PathPart('') Args() {
54     my ( $self, $c ) = @_;
55     $c->response->body( 'Page not found' );
56     $c->response->status(404);
57 }
58
59 sub end : Action {}
60
61 __PACKAGE__->meta->make_immutable;
62
63 1;