Commit | Line | Data |
82300460 |
1 | package # Hide from PAUSE |
2 | TestApp::Controller::Root; |
3 | |
4 | use base qw(Catalyst::Controller); |
5 | |
6 | sub default : Private { |
7 | my ( $self, $c ) = @_; |
8 | |
9 | $c->res->body(qq{Nothing Here}); |
10 | } |
11 | |
12 | sub email : Global('email') { |
13 | my ($self, $c, @args) = @_; |
14 | |
15 | my $time = $c->req->params->{time} || time; |
16 | |
17 | $c->stash->{email} = { |
fd0033bc |
18 | to => 'test-email@example.com', |
19 | from => 'no-reply@example.com', |
82300460 |
20 | subject => 'Email Test', |
21 | body => "Email Sent at: $time" |
22 | }; |
23 | |
24 | $c->forward('TestApp::View::Email'); |
25 | |
26 | if ( scalar( @{ $c->error } ) ) { |
27 | $c->res->status(500); |
28 | $c->res->body('Email Failed'); |
29 | } else { |
30 | $c->res->body('Plain Email Ok'); |
31 | } |
32 | } |
33 | |
25650747 |
34 | sub email_app_config : Global('email_app_config') { |
35 | my ($self, $c, @args) = @_; |
36 | |
37 | my $time = $c->req->params->{time} || time; |
38 | |
39 | $c->stash->{email} = { |
40 | to => 'test-email@example.com', |
41 | from => 'no-reply@example.com', |
42 | subject => 'Email Test', |
43 | body => "Email Sent at: $time" |
44 | }; |
45 | |
46 | $c->forward('TestApp::View::Email::AppConfig'); |
47 | |
48 | if ( scalar( @{ $c->error } ) ) { |
49 | $c->res->status(500); |
50 | $c->res->body('Email Failed'); |
51 | } else { |
52 | $c->res->body('Plain Email Ok'); |
53 | } |
54 | } |
55 | |
82300460 |
56 | sub template_email : Global('template_email') { |
57 | my ($self, $c, @args) = @_; |
58 | |
59 | $c->stash->{time} = $c->req->params->{time} || time; |
60 | |
61 | $c->stash->{email} = { |
fd0033bc |
62 | to => 'test-email@example.com', |
63 | from => 'no-reply@example.com', |
82300460 |
64 | subject => 'Just a test', |
82300460 |
65 | templates => [ |
06afcdbc |
66 | { |
06afcdbc |
67 | template => 'text_plain/test.tt', |
68 | content_type => 'text/plain', |
69 | }, |
70 | { |
71 | view => 'TT', |
72 | template => 'text_html/test.tt', |
73 | content_type => 'text/html', |
74 | }, |
75 | ], |
82300460 |
76 | }; |
77 | |
78 | $c->forward('TestApp::View::Email::Template'); |
79 | |
80 | if ( scalar( @{ $c->error } ) ) { |
81 | $c->res->status(500); |
82 | $c->res->body('Template Email Failed'); |
83 | } else { |
84 | $c->res->body('Template Email Ok'); |
85 | } |
86 | } |
87 | |
8b10ee55 |
88 | sub template_email_app_config : Global('template_email_app_config') { |
89 | my ($self, $c, @args) = @_; |
90 | |
91 | $c->stash->{time} = $c->req->params->{time} || time; |
92 | |
93 | $c->stash->{template_email} = { |
94 | to => 'test-email@example.com', |
95 | from => 'no-reply@example.com', |
96 | subject => 'Just a test', |
8b10ee55 |
97 | templates => [ |
06afcdbc |
98 | { |
99 | template => 'text_plain/test.tt', |
100 | content_type => 'text/plain', |
101 | }, |
102 | { |
ea115f9b |
103 | view => 'TT', |
06afcdbc |
104 | template => 'text_html/test.tt', |
105 | content_type => 'text/html', |
106 | }, |
107 | ], |
8b10ee55 |
108 | }; |
109 | |
110 | $c->forward('TestApp::View::Email::Template::AppConfig'); |
111 | |
112 | if ( scalar( @{ $c->error } ) ) { |
113 | $c->res->status(500); |
114 | $c->res->body('Template Email Failed'); |
115 | } else { |
116 | $c->res->body('Template Email Ok'); |
117 | } |
118 | } |
119 | |
120 | sub mason_email : Global('mason_email') { |
121 | my ($self, $c, @args) = @_; |
122 | |
123 | $c->stash->{time} = $c->req->params->{time} || time; |
124 | |
125 | $c->stash->{email} = { |
126 | to => 'test-email@example.com', |
127 | from => 'no-reply@example.com', |
128 | subject => 'Just a test', |
8b10ee55 |
129 | templates => [ |
06afcdbc |
130 | { |
c649c40e |
131 | template => 'text_plain/test.m', |
06afcdbc |
132 | content_type => 'text/plain', |
133 | }, |
134 | { |
ea115f9b |
135 | view => 'Mason', |
c649c40e |
136 | template => 'text_html/test.m', |
06afcdbc |
137 | content_type => 'text/html', |
138 | }, |
139 | ], |
8b10ee55 |
140 | }; |
141 | |
142 | $c->forward('TestApp::View::Email::Template'); |
143 | |
144 | if ( scalar( @{ $c->error } ) ) { |
145 | $c->res->status(500); |
146 | $c->res->body('Mason Email Failed'); |
147 | } else { |
148 | $c->res->body('Mason Email Ok'); |
149 | } |
150 | } |
151 | |
152 | |
82300460 |
153 | 1; |