blob: 19f5ab32b462bee409b7ccf4e90101142043a244 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package FixMyStreet::FakeQ;
use strict;
use warnings;
use Carp;
=head1 NAME
FixMyStreet::FakeQ - adaptor object to ease code transition
=head1 DESCRIPTION
The old code uses '$q' everywhere - partly to passaround which cobrand is in
use, partly to give access to the request query parameters and partly as a
scratch pad.
This object lets us fake this behaviour in a structured way so that the new
Catalyst based code can call the old CGI code with no need for changes.
Eventually it will be phased out.
=head1 METHODS
=head2 new
$fake_q = FixMyStreet::FakeQ->new( $args );
Create a new FakeQ object. Checks that 'site' argument is present and corrects
it if needed.
=cut
sub new {
my $class = shift;
my $args = shift || {};
croak "required argument 'site' missing" unless $args->{site};
$args->{site} = 'fixmystreet' if $args->{site} eq 'default';
$args->{params} ||= {};
return bless $args, $class;
}
=head2 param
$val = $fake_q->param( 'key' );
Behaves much like CGI's ->param. Returns value if found, or undef if not.
=cut
sub param {
my $self = shift;
my $key = shift;
return $self->{params}->{$key};
}
1;
|