/**
* This method exists because the service container needs to be set before
* the page's functionality gets loaded.
*/
public function initialize()
{
// because some cronjobs will be run on the command line we should pass parameters
if (isset($_SERVER['argv'])) {
// init var
$first = true;
// loop all passes arguments
foreach ($_SERVER['argv'] as $parameter) {
// ignore first, because this is the scripts name.
if ($first) {
// reset
$first = false;
// skip
continue;
}
// split into chunks
$chunks = explode('=', $parameter, 2);
// valid parameters?
if (count($chunks) == 2) {
// build key and value
$key = trim($chunks[0], '--');
$value = $chunks[1];
// set in GET
if ($key != '' && $value != '') {
$_GET[$key] = $value;
}
}
}
}
// define the Named Application
if (!defined('NAMED_APPLICATION')) {
define('NAMED_APPLICATION', 'Backend');
}
// set the module
$this->setModule(\SpoonFilter::toCamelCase(\SpoonFilter::getGetValue('module', null, '')));
// set the requested file
$this->setAction(\SpoonFilter::toCamelCase(\SpoonFilter::getGetValue('action', null, '')));
// set the language
$this->setLanguage(\SpoonFilter::getGetValue('language', FrontendLanguage::getActiveLanguages(), SITE_DEFAULT_LANGUAGE));
// mark cronjob as run
$cronjobs = (array) $this->get('fork.settings')->get('Core', 'cronjobs');
$cronjobs[] = $this->getModule() . '.' . $this->getAction();
$this->get('fork.settings')->set('Core', 'cronjobs', array_unique($cronjobs));
$this->execute();
}