/**
* This method exists because the service container needs to be set before
* the request's functionality gets loaded.
*/
public function initialize()
{
$request = $this->getContainer()->get('request');
// get vars
if ($request->request->has('fork')) {
$post = $request->request->get('fork');
$module = isset($post['module']) ? $post['module'] : '';
$action = isset($post['action']) ? $post['action'] : '';
$language = isset($post['language']) ? $post['language'] : '';
} else {
$module = $request->query->get('module');
$action = $request->query->get('action');
$language = $request->query->get('language');
}
if ($language == '') {
$language = SITE_DEFAULT_LANGUAGE;
}
try {
$this->setModule($module);
$this->setAction($action);
$this->setLanguage($language);
if (extension_loaded('newrelic')) {
newrelic_name_transaction('ajax::' . $module . '::' . $action);
}
$this->ajaxAction = new AjaxAction($this->getKernel(), $this->getAction(), $this->getModule());
$this->output = $this->ajaxAction->execute();
} catch (InvalidArgumentException $e) {
$message = Model::getContainer()->getParameter('fork.debug_message');
$this->ajaxAction = new FrontendBaseAJAXAction($this->getKernel(), '', '');
$this->ajaxAction->output(FrontendBaseAJAXAction::ERROR, null, $message);
$this->output = $this->ajaxAction->execute();
} catch (Exception $e) {
if (Model::getContainer()->getParameter('kernel.debug')) {
$message = $e->getMessage();
} else {
$message = Model::getContainer()->getParameter('fork.debug_message');
}
$this->ajaxAction = new FrontendBaseAJAXAction($this->getKernel(), '', '');
$this->ajaxAction->output(FrontendBaseAJAXAction::ERROR, null, $message);
$this->output = $this->ajaxAction->execute();
}
}