Refactor out the check for the session-request outside of the nested
conditionals. Use the hashref out of the request object to speed up param name lookups.
This commit is contained in:
parent
05e563f79d
commit
118399c1db
1 changed files with 11 additions and 20 deletions
|
|
@ -103,27 +103,18 @@ The name of the field to retrieve if you want to retrieve just one specific fiel
|
||||||
|
|
||||||
sub param {
|
sub param {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
return undef unless $self->session->request;
|
||||||
my $field = shift;
|
my $field = shift;
|
||||||
if ($field) {
|
if ($field) {
|
||||||
if ($self->session->request) {
|
my @data = $self->session->request->param($field);
|
||||||
my @data = $self->session->request->param($field);
|
foreach my $value (@data) {
|
||||||
foreach my $value (@data) {
|
$value = Encode::decode_utf8($value);
|
||||||
$value = Encode::decode_utf8($value);
|
}
|
||||||
}
|
return wantarray ? @data : $data[0];
|
||||||
return wantarray ? @data : $data[0];
|
}
|
||||||
} else {
|
else {
|
||||||
return undef;
|
my $paramRef = $self->session->request->param;
|
||||||
}
|
return keys %{ $paramRef };
|
||||||
} else {
|
|
||||||
if ($self->session->request) {
|
|
||||||
my %params;
|
|
||||||
foreach ($self->session->request->param) {
|
|
||||||
$params{$_} = 1;
|
|
||||||
}
|
|
||||||
return keys %params;
|
|
||||||
} else {
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,8 +145,8 @@ A full set of form params just as you'd pass into any of the form controls when
|
||||||
sub process {
|
sub process {
|
||||||
my ($self, $name, $type, $default, $params) = @_;
|
my ($self, $name, $type, $default, $params) = @_;
|
||||||
|
|
||||||
$type = ucfirst($type);
|
|
||||||
return $self->param($name) if ($type eq "");
|
return $self->param($name) if ($type eq "");
|
||||||
|
$type = ucfirst($type);
|
||||||
|
|
||||||
return $self->SUPER::process({
|
return $self->SUPER::process({
|
||||||
name => $name,
|
name => $name,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue