'starter' => 'deprecated',
];
+ /**
+ * Detected application's name
+ */
+ private static $detectedApplicationName;
+
+ /**
+ * Detected application's full path
+ */
+ private static $detectedApplicationPath;
+
/**
* Private constructor, no instance is needed from this class as only
* static methods exist.
return self::$configurationInstance;
}
+ /**
+ * Getter for detected application name
+ *
+ * @return $detectedApplicationName Detected name of application
+ */
+ public static function getDetectedApplicationName () {
+ return self::$detectedApplicationName;
+ }
+
+ /**
+ * Getter for detected application's full path
+ *
+ * @return $detectedApplicationPath Detected full path of application
+ */
+ public static function getDetectedApplicationPath () {
+ return self::$detectedApplicationPath;
+ }
+
/**
* "Getter" to get response/request type from analysis of the system.
*
/*
* 2) Determine the request type, console or web and store request and
- * response here. This also initializes the request instance will
+ * response here. This also initializes the request instance with
* all given parameters (see doc-tag for possible sources of
* parameters).
*/
* @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');
-
/*
* Now check and load all files, found deprecated files will throw a
* warning at the user.
*/
foreach (self::$configAppIncludes as $fileName => $status) {
// Construct file instance
- $fileInstance = new SplFileInfo(sprintf('%s%s.php', $fullPath, $fileName));
+ $fileInstance = new SplFileInfo(sprintf('%s%s.php', self::getDetectedApplicationPath(), $fileName));
// Determine if this file is wanted/readable/deprecated
if (($status == 'required') && (!self::isReadableFile($fileInstance))) {
// Nope, required file cannot be found/read from
- ApplicationEntryPoint::exitApplication(sprintf('Application "%s" does not have required file "%s.php". Please add it.', $application, $fileInstance->getBasename()));
+ ApplicationEntryPoint::exitApplication(sprintf('Application "%s" does not have required file "%s.php". Please add it.', self::getDetectedApplicationName(), $fileInstance->getBasename()));
} elseif (($fileInstance->isFile()) && (!$fileInstance->isReadable())) {
// Found, not readable file
- ApplicationEntryPoint::exitApplication(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileInstance->getBasename(), $application));
+ ApplicationEntryPoint::exitApplication(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileInstance->getBasename(), self::getDetectedApplicationName()));
} elseif (($status != 'required') && (!self::isReadableFile($fileInstance))) {
// Not found but optional/deprecated file, skip it
continue;
// Is the file deprecated?
if ($status == 'deprecated') {
// Issue warning
- trigger_error(sprintf('Deprecated file "%s.php" found, will not load it to avoid problems. Please remove it from your application "%s" to avoid this warning.', $fileName, $application), E_USER_WARNING);
+ trigger_error(sprintf('Deprecated file "%s.php" found, will not load it to avoid problems. Please remove it from your application "%s" to avoid this warning.', $fileName, self::getDetectedApplicationName()), E_USER_WARNING);
// Skip loading deprecated file
continue;
* @return void
*/
public static function startApplication () {
- // 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(
array(
if ((empty($applicationInstance)) || (is_null($applicationInstance))) {
// Something went wrong!
ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the helper class <span class="class_name">%s</span> is not loaded.',
- $application,
+ self::getDetectedApplicationName(),
'Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper'
));
} elseif (!is_object($applicationInstance)) {
// No object!
ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because 'app' is not an object (%s).',
- $application,
+ self::getDetectedApplicationName(),
gettype($applicationInstance)
));
} elseif (!($applicationInstance instanceof ManageableApplication)) {
// Missing interface
ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because 'app' is lacking required interface ManageableApplication.',
- $application
+ self::getDetectedApplicationName()
));
}
}
// Get it for local usage
- $application = self::getRequestInstance()->getRequestElement('app');
+ $applicationName = self::getRequestInstance()->getRequestElement('app');
// Secure it, by keeping out tags
- $application = htmlentities(strip_tags($application), ENT_QUOTES);
+ $applicationName = htmlentities(strip_tags($applicationName), ENT_QUOTES);
// Secure it a little more with a reg.exp.
- $application = preg_replace('/([^a-z0-9_-])+/i', '', $application);
+ $applicationName = preg_replace('/([^a-z0-9_-])+/i', '', $applicationName);
// Construct FQPN (Full-Qualified Path Name) for ApplicationHelper class
$applicationPath = sprintf(
'%s%s%s',
self::getConfigurationInstance()->getConfigEntry('application_base_path'),
- $application,
+ $applicationName,
DIRECTORY_SEPARATOR
);
// Is the path there? This secures a bit the parameter (from untrusted source).
if ((!is_dir($applicationPath)) || (!is_readable($applicationPath))) {
// Not found or not readable
- ApplicationEntryPoint::exitApplication(sprintf('Application "%s" not found.', $application));
+ ApplicationEntryPoint::exitApplication(sprintf('Application "%s" not found.', $applicationName));
}
// 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::$detectedApplicationPath = $applicationPath;
+ self::$detectedApplicationName = $applicationName;
}
/**