CGI-Mungo
view release on metacpan or search on metacpan
lib/CGI/Mungo.pm view on Meta::CPAN
=head2 getResponse()
my $response = $m->getResponse();
Returns an instance of the response plugin object, previously defined in the constructor options.
See L<CGI::Mungo::Response> for more details.
=cut
###########################################################
sub getResponse{
my $self = shift;
return $self->{'_response'};
}
#########################################################
=pod
=head2 getSession()
my $session = $m->getSession();
Returns an instance of the L<CGI::Mungo::Session> object.
=cut
###########################################################
sub getSession{
my $self = shift;
return $self->{'_session'};
}
#########################################################
=pod
=head2 getRequest()
my $request = $m->getRequest();
Returns an instance of the L<CGI::Mungo::Request> object.
=cut
###########################################################
sub getRequest{
my $self = shift;
my $request = $self->{'_request'};
if(!$request){
confess("No request object found");
}
return $request;
}
#########################################################
=pod
=head2 setActions(\%actions)
my %actions = (
'default' => \&showMenu().
'list' => \%showList()
)
$m->setActions(\%actions);
Sets the actions of the web application using a hash reference. The names of the keys in the hash
reference will match the value of the given "action" form field from the current request. Hash reference values
can be references to subs or annoymous subs.
An action of 'default' can be used when a visitor does not request a specific action.
=cut
###########################################################
sub setActions{
my($self, $actions) = @_;
$self->{'_actions'} = $actions;
return 1;
}
#########################################################
=pod
=head2 getAction()
my $action = $m->getAction();
Returns the curent action that the web application is performing. This is the current value of the "action"
request form field or query string item.
If search engine friendly URLs are turned on the action will be determined from the last part of the script URL.
=cut
###########################################################
sub getAction{
my $self = shift;
my $action = "default";
if(defined($self->getOption('sefUrls')) && $self->getOption('sefUrls')){ #do we have search engine friendly urls
my $sefAction = $self->_getSefAction();
if($sefAction){
$action = $sefAction;
}
}
else{ #get action from query string or post string
my $request = $self->getRequest();
my $params = $request->getParameters();
if(defined($params->{'action'})){
$action = $params->{'action'};
}
}
return $action;
}
#########################################################
=pod
=head2 getFullUrl()
my $url = $m->getFullUrl();
( run in 1.039 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )