protected function initialize()
{
if ($this->get('serverData') === null) {
$this->set('serverData', (array) $_SERVER);
}
if ($this->get('getData') === null) {
$this->set('getData', (array) $_GET);
}
if ($this->get('postData') === null) {
$this->set('postData', (array) $_POST);
}
if ($this->get('sessionData') === null && isset($_SESSION)) {
$this->set('sessionData', (array) $_GET);
}
$serverData = $this->get('serverData');
if (!$this->get('projectRoot')) {
$projectRoot = isset($serverData['_']) ? $serverData['_'] : $serverData['DOCUMENT_ROOT'];
$this->set('projectRoot', $projectRoot);
}
if (!$this->get('url')) {
if (isset($serverData['REDIRECT_URL'])) {
$this->set('url', $serverData['REDIRECT_URL']);
} elseif (isset($serverData['SCRIPT_NAME'])) {
$this->set('url', $serverData['SCRIPT_NAME']);
}
}
if (!$this->get('hostname')) {
$this->set('hostname', isset($serverData['HTTP_HOST']) ? $serverData['HTTP_HOST'] : 'No Host');
}
$protocol = $this->get('secure') ? 'https' : 'http';
$endPoint = $this->get('apiEndPoint') ?: $protocol . '://' . $this->get('host') . $this->get('resource');
$this->set('apiEndPoint', $endPoint);
}