X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fbootstrap%2Fclass_FrameworkBootstrap.php;h=f6fe09405315bbfb7a97361f4f037ffe76508934;hb=63261187e2d5767e127cfafe5c9b7abb4539b6d3;hp=5d9aa02757ef55375523b11c3d96fae8d16c9ff9;hpb=2fe9cb99d3b4f2ea423a9205511fc50d64c2af8c;p=core.git
diff --git a/framework/bootstrap/class_FrameworkBootstrap.php b/framework/bootstrap/class_FrameworkBootstrap.php
index 5d9aa027..f6fe0940 100644
--- a/framework/bootstrap/class_FrameworkBootstrap.php
+++ b/framework/bootstrap/class_FrameworkBootstrap.php
@@ -105,6 +105,16 @@ final class FrameworkBootstrap {
'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.
@@ -129,6 +139,24 @@ final class FrameworkBootstrap {
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.
*
@@ -270,7 +298,7 @@ final class FrameworkBootstrap {
/*
* 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).
*/
@@ -292,25 +320,21 @@ final class FrameworkBootstrap {
* @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;
@@ -319,7 +343,7 @@ final class FrameworkBootstrap {
// 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;
@@ -340,9 +364,6 @@ final class FrameworkBootstrap {
* @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(
@@ -354,19 +375,19 @@ final class FrameworkBootstrap {
if ((empty($applicationInstance)) || (is_null($applicationInstance))) {
// Something went wrong!
ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application %s could not be launched because the helper class %s is not loaded.',
- $application,
+ self::getDetectedApplicationName(),
'Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper'
));
} elseif (!is_object($applicationInstance)) {
// No object!
ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application %s 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 %s could not be launched because 'app' is lacking required interface ManageableApplication.',
- $application
+ self::getDetectedApplicationName()
));
}
@@ -628,19 +649,19 @@ final class FrameworkBootstrap {
}
// 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
);
@@ -648,12 +669,12 @@ final class FrameworkBootstrap {
// 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;
}
/**