* Includes applications may have. They will be tried in the given order,
* some will become soon deprecated.
*/
- private static $configAppIncludes = array(
+ private static $configAppIncludes = [
// The ApplicationHelper class (required)
'class_ApplicationHelper' => 'required',
// Some debugging stuff (optional but can be committed)
'init' => 'deprecated',
// Application starter (deprecated)
'starter' => 'deprecated',
- );
+ ];
/**
* Private constructor, no instance is needed from this class as only
if (is_null(self::$configurationInstance)) {
// Init new instance
self::$configurationInstance = new FrameworkConfiguration();
- } // END - if
+ }
// Return it
return self::$configurationInstance;
if (isset($_SERVER['HTTP_HOST'])) {
// Then it is a HTML response/request.
$requestType = 'html';
- } // END - if
+ }
// Return it
return $requestType;
// Abort lookup as it has been found in open_basedir
break;
- } // END - if
- } // END - foreach
+ }
+ }
} else {
// If open_basedir is not set, all is allowed
$isReachable = true;
if (!self::isReadableFile($fileInstance)) {
// Abort here
throw new InvalidArgumentException(sprintf('Cannot find fileInstance.pathname=%s.', $fileInstance->getPathname()));
- } // END - if
+ }
// Load it
require_once $fileInstance->getPathname();
* @return void
*/
public static function prepareApplication () {
- // Configuration entry 'detected_app_name' must be set, get it here, including full path
- $application = self::getConfigurationInstance()->getConfigEntry('detected_app_name');
- $fullPath = self::getConfigurationInstance()->getConfigEntry('detected_full_app_path');
+ // Configuration entry '__detected_app_name' must be set, get it here, including full path
+ $application = self::getConfigurationInstance()->getConfigEntry('__detected_app_name');
+ $fullPath = self::getConfigurationInstance()->getConfigEntry('__detected_full_app_path');
/*
* Now check and load all files, found deprecated files will throw a
// Skip loading deprecated file
continue;
- } // END - if
+ }
// Load it
self::loadInclude($fileInstance);
- } // END - foreach
+ }
// Scan for application's classes, exceptions and interfaces
ClassLoader::scanApplicationClasses();
* @return void
*/
public static function startApplication () {
- // Configuration entry 'detected_app_name' must be set, get it here
- $application = self::getConfigurationInstance()->getConfigEntry('detected_app_name');
+ // Configuration entry '__detected_app_name' must be set, get it here
+ $application = self::getConfigurationInstance()->getConfigEntry('__detected_app_name');
// Is there an application helper instance?
$applicationInstance = call_user_func_array(
// Call method
call_user_func(array($applicationInstance, $methodName));
- } // END - foreach
+ }
}
/**
if (self::getDatabaseInstance() instanceof DatabaseConnector) {
// Yes, then abort here
throw new BadMethodCallException('Method called twice.');
- } // END - if
+ }
// Initialize database layer
$databaseInstance = ObjectFactory::createObjectByConfiguredName(self::getConfigurationInstance()->getConfigEntry('database_type') . '_class');
* false as many other PHP functions are doing? ;-(
*/
throw new UnknownHostnameException(sprintf('Cannot resolve "%s" to an IP address. Please fix your setup.', $_SERVER['SERVER_NAME']));
- } // END - if
+ }
// Al fine, set it
self::$serverAddress = $serverIp;
// Run auto-detecting through console tools lib
self::$serverAddress = ConsoleTools::acquireSelfIpAddress();
}
- } // END - if
+ }
// Return it
return self::$serverAddress;
if (self::isHttpSecured()) {
// Add the >s< for HTTPS
$protocol = 'https';
- } // END - if
+ }
// Construct the full URL and secure it against CSRF attacks
$baseUrl = sprintf('%s://%s%s', $protocol, self::detectDomain(), self::detectScriptPath());
if (isset($_SERVER['SERVER_NAME'])) {
// Detect the full domain
$fullDomain = htmlentities(strip_tags($_SERVER['SERVER_NAME']), ENT_QUOTES);
- } // END - if
+ }
// Return it
return $fullDomain;
if (isset($_SERVER['SCRIPT_NAME'])) {
// Get dirname from it and replace back-slashes with slashes for lame OSes...
$scriptPath = str_replace("\\", '/', dirname($_SERVER['SCRIPT_NAME']));
- } // END - if
+ }
// Return it
return $scriptPath;
// Then use it
$request = strtolower($requestInstance->getRequestElement('request'));
$requestType = $request;
- } // END - if
+ }
// ... and a new response object
$responseClass = sprintf('Org\Mxchange\CoreFramework\Response\%sResponse', StringUtils::convertToClassName($request));
* application (by user).
*/
ApplicationEntryPoint::exitApplication('No application specified. Please provide a parameter "app" and retry.');
- } // END - if
+ }
// Get it for local usage
$application = self::getRequestInstance()->getRequestElement('app');
if ((!is_dir($applicationPath)) || (!is_readable($applicationPath))) {
// Not found or not readable
ApplicationEntryPoint::exitApplication(sprintf('Application "%s" not found.', $application));
- } // END - if
+ }
// Set the detected application's name and full path for later usage
- self::getConfigurationInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
- self::getConfigurationInstance()->setConfigEntry('detected_app_name' , $application);
+ self::getConfigurationInstance()->setConfigEntry('__detected_full_app_path', $applicationPath);
+ self::getConfigurationInstance()->setConfigEntry('__detected_app_name' , $application);
}
/**