NAME
Kernel::System::Web::Request – legacy wrapper for Mojolicious
PUBLIC INTERFACE
new()
create param object. Do not use it directly, instead use:
use Kernel::System::ObjectManager;
local $Kernel::OM = Kernel::System::ObjectManager->new(
'Kernel::System::Web::Request' => {
Controller => $Controller,
}
);
my $ParamObject = $Kernel::OM->Get('Kernel::System::Web::Request');
GetParam()
to get single request parameters. By default, trimming is performed on the data.
my $Param = $ParamObject->GetParam(
Param => 'ID',
Raw => 1, # optional, input data is not changed
);
GetParamNames()
to get names of all parameters passed to the script.
my @ParamNames = $ParamObject->GetParamNames();
Example:
Called URL: index.pl?Action=AdminSystemConfiguration;Subaction=Save;Name=Config::Option::Valid
my @ParamNames = $ParamObject->GetParamNames();
print join " :: ", @ParamNames;
#prints Action :: Subaction :: Name
GetArray()
to get array request parameters. By default, trimming is performed on the data.
my @Param = $ParamObject->GetArray(
Param => 'ID',
Raw => 1, # optional, input data is not changed
);
GetUploadAll()
gets file upload data.
my %File = $ParamObject->GetUploadAll(
Param => 'FileParam', # the name of the request parameter containing the file data
);
returns (
Filename => 'abc.txt',
ContentType => 'text/plain',
Content => 'Some text',
);
SetCookie()
set a cookie
$ParamObject->SetCookie(
Key => ID,
Value => 123456,
Expires => $Epoch,
Path => 'otrs/', # optional, only allow cookie for given path
Secure => 1, # optional, set secure attribute to disable cookie on HTTP (HTTPS only)
HTTPOnly => 1, # optional, sets HttpOnly attribute of cookie to prevent access via JavaScript
);
GetCookie()
get a cookie
my $String = $ParamObject->GetCookie(
Key => ID,
);
IsAJAXRequest()
checks if the current request was sent by AJAX
my $IsAJAXRequest = $ParamObject->IsAJAXRequest();
LoadFormDraft()
Load specified draft. This will read stored draft data and inject it into the param object for transparent use by frontend module.
my $FormDraftID = $ParamObject->LoadFormDraft(
FormDraftID => 123,
UserID => 1,
);
SaveFormDraft()
Create or replace draft using data from param object and upload cache. Specified params can be overwritten if necessary.
my $FormDraftID = $ParamObject->SaveFormDraft(
UserID => 1
ObjectType => 'Ticket',
ObjectID => 123,
OverrideParams => { # optional, can contain strings and array references
Subaction => undef,
UserID => 1,
CustomParam => [ 1, 2, 3, ],
...
},
);