d42ab6770f28ae6dda2ae5e3eb3e26500bfe22ed
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Action / Chained / CaptureArgs.pm
1 package TestApp::Controller::Action::Chained::CaptureArgs;
2 use warnings;
3 use strict;
4
5 use base qw( Catalyst::Controller );
6
7 #
8 #   This controller build the following patterns of URI:
9 #      /captureargs/*/*
10 #      /captureargs/*/*/edit
11 #      /captureargs/*
12 #      /captureargs/*/edit
13 #      /captureargs/test/*
14 #   It will output the arguments they got passed to @_ after the
15 #   context object. 
16 #   /captureargs/one/edit should not dispatch to /captureargs/*/*
17 #   /captureargs/test/one should not dispatch to /captureargs/*/*
18
19 sub base  :Chained('/') PathPart('captureargs') CaptureArgs(0) {
20     my ( $self, $c, $arg ) = @_;
21     push @{ $c->stash->{ passed_args } }, 'base';
22 }
23
24 sub two_args :Chained('base') PathPart('') CaptureArgs(2) {
25     my ( $self, $c, $arg1, $arg2 ) = @_;
26     push @{ $c->stash->{ passed_args } }, 'two_args', $arg1, $arg2;
27 }
28
29 sub one_arg :Chained('base') ParthPart('') CaptureArgs(1) {
30     my ( $self, $c, $arg ) = @_;
31     push @{ $c->stash->{ passed_args } }, 'one_arg', $arg;
32 }
33
34 sub edit_two_args  :Chained('two_args') PathPart('edit') Args(0) {
35     my ( $self, $c ) = @_;
36     push @{ $c->stash->{ passed_args } }, 'edit_two_args';
37 }
38
39 sub edit_one_arg :Chained('one_arg') PathPart('edit') Args(0) {
40     my ( $self, $c ) = @_;
41     push @{ $c->stash->{ passed_args } }, 'edit_one_arg';
42 }
43
44 sub view_two_args :Chained('two_args') PathPart('') Args(0) {
45     my ( $self, $c ) = @_;
46     push @{ $c->stash->{ passed_args } }, 'view_two_args';
47 }
48
49 sub view_one_arg :Chained('one_arg') PathPart('') Args(0) {
50     my ( $self, $c ) = @_;
51     push @{ $c->stash->{ passed_args } }, 'view_one_arg';
52 }
53
54 sub test_plus_arg :Chained('base') PathPart('test') Args(1) {
55     my ( $self, $c, $arg ) = @_;
56     push @{ $c->stash->{ passed_args } }, 'test_plus_arg', $arg;
57 }
58
59
60 sub end : Private {
61     my ( $self, $c ) = @_;
62     no warnings 'uninitialized';
63     $c->response->body( join '; ', @{ $c->stash->{ passed_args } } );
64 }
65
66 1;