X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fbootstrap%2Fclass_FrameworkBootstrap.php;h=fb7d036546afdf63443efd202aa74f3fb5244cc3;hb=0602f1ce534b364bda168985181e5882bb6e5fd7;hp=2af601e0d5971c06195dc2cc9107dbc296153cf5;hpb=5da8f717122568335b8a8ab230fa0de17e983fab;p=core.git
diff --git a/framework/bootstrap/class_FrameworkBootstrap.php b/framework/bootstrap/class_FrameworkBootstrap.php
index 2af601e0..fb7d0365 100644
--- a/framework/bootstrap/class_FrameworkBootstrap.php
+++ b/framework/bootstrap/class_FrameworkBootstrap.php
@@ -1,27 +1,28 @@
getPathname(), 0, strlen($dir)) == $dir) {
// Is reachable
$isReachable = true;
+
+ // Abort lookup as it has been found in open_basedir
+ break;
} // END - if
} // END - foreach
} else {
@@ -170,23 +195,21 @@ final class FrameworkBootstrap {
* Checks whether the give file is within open_basedir() (done by
* isReachableFilePath()), is actually a file and is readable.
*
- * @param $fileName Name of the file to be checked
+ * @param $fileInstance An instance of a SplFileInfo class
* @return $isReadable Whether the file is readable (and therefor exists)
*/
- public static function isReadableFile ($fileName) {
+ public static function isReadableFile (SplFileInfo $fileInstance) {
// Default is not readable
$isReadable = false;
- // Is within parameters, so check if it is a file and readable
+ // Check if it is a file and readable
$isReadable = (
(
- self::isReachableFilePath($fileName)
- ) && (
- file_exists($fileName)
+ self::isReachableFilePath($fileInstance)
) && (
- is_file($fileName)
+ $fileInstance->isFile()
) && (
- is_readable($fileName)
+ $fileInstance->isReadable()
)
);
@@ -197,22 +220,22 @@ final class FrameworkBootstrap {
/**
* Loads given include file
*
- * @param $fqfn Include's FQFN
+ * @param $fileInstance An instance of a SplFileInfo class
* @return void
- * @throws InvalidArgumentException If $fqfn was not found or not readable or deprecated
+ * @throws InvalidArgumentException If file was not found or not readable or deprecated
*/
- public static function loadInclude ($fqfn) {
+ public static function loadInclude (SplFileInfo $fileInstance) {
// Trace message
- //* NOISY-DEBUG: */ printf('[%s:%d]: fqfn=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fqfn);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: fileInstance=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $fileInstance);
// Should be there ...
- if (!self::isReadableFile($fqfn)) {
+ if (!self::isReadableFile($fileInstance)) {
// Abort here
- throw new InvalidArgumentException(sprintf('Cannot find fqfn=%s.', $fqfn));
+ throw new InvalidArgumentException(sprintf('Cannot find fileInstance.pathname=%s.', $fileInstance->getPathname()));
} // END - if
// Load it
- require $fqfn;
+ require $fileInstance->getPathname();
// Trace message
//* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
@@ -225,12 +248,13 @@ final class FrameworkBootstrap {
*/
public static function doBootstrap () {
// Load basic include files to continue bootstrapping
- self::loadInclude(sprintf('%smain%sinterfaces%sclass_FrameworkInterface.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR));
- self::loadInclude(sprintf('%smain%sinterfaces%sregistry%sclass_Registerable.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR));
- self::loadInclude(sprintf('%sconfig%sclass_FrameworkConfiguration.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR));
+ self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sclass_FrameworkInterface.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
+ self::loadInclude(new SplFileInfo(sprintf('%smain%sclasses%sclass_BaseFrameworkSystem.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
+ self::loadInclude(new SplFileInfo(sprintf('%smain%sinterfaces%sregistry%sclass_Registerable.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)));
+ self::loadInclude(new SplFileInfo(sprintf('%sconfig%sclass_FrameworkConfiguration.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR)));
// Load global configuration
- self::loadInclude(sprintf('%s%s', ApplicationEntryPoint::detectFrameworkPath(), 'config-global.php'));
+ self::loadInclude(new SplFileInfo(sprintf('%s%s', ApplicationEntryPoint::detectFrameworkPath(), 'config-global.php')));
}
/**
@@ -274,25 +298,25 @@ final class FrameworkBootstrap {
*/
public static function prepareApplication () {
// Configuration entry 'detected_app_name' must be set, get it here, including full path
- $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('detected_app_name');
- $fullPath = FrameworkConfiguration::getSelfInstance()->getConfigEntry('detected_full_app_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 FQFN
- $fqfn = sprintf('%s%s.php', $fullPath, $fileName);
+ // Construct file instance
+ $fileInstance = new SplFileInfo(sprintf('%s%s.php', $fullPath, $fileName));
// Determine if this file is wanted/readable/deprecated
- if (($status == 'required') && (!self::isReadableFile($fqfn))) {
+ 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, $fileName));
- } elseif ((file_exists($fqfn)) && (!is_readable($fqfn))) {
+ ApplicationEntryPoint::exitApplication(sprintf('Application "%s" does not have required file "%s.php". Please add it.', $application, $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.', $fileName, $application));
- } elseif (($status != 'required') && (!self::isReadableFile($fqfn))) {
+ ApplicationEntryPoint::exitApplication(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileInstance->getBasename(), $application));
+ } elseif (($status != 'required') && (!self::isReadableFile($fileInstance))) {
// Not found but optional/deprecated file, skip it
continue;
}
@@ -307,7 +331,7 @@ final class FrameworkBootstrap {
} // END - if
// Load it
- self::loadInclude($fqfn);
+ self::loadInclude($fileInstance);
} // END - foreach
// Scan for application's classes, exceptions and interfaces
@@ -322,31 +346,31 @@ final class FrameworkBootstrap {
*/
public static function startApplication () {
// Configuration entry 'detected_app_name' must be set, get it here
- $application = FrameworkConfiguration::getSelfInstance()->getConfigEntry('detected_app_name');
+ $application = self::getConfigurationInstance()->getConfigEntry('detected_app_name');
// Is there an application helper instance?
$applicationInstance = call_user_func_array(
array(
- 'CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
+ 'Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
), array()
);
// Some sanity checks
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.",
+ ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application %s could not be launched because the helper class %s is not loaded.',
$application,
- 'CoreFramework\Helper\Application\ApplicationHelper'
+ '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).",
+ ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application %s could not be launched because 'app' is not an object (%s).',
$application,
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.",
+ ApplicationEntryPoint::exitApplication(sprintf('[Main:] The application %s could not be launched because 'app' is lacking required interface ManageableApplication.',
$application
));
}
@@ -361,7 +385,7 @@ final class FrameworkBootstrap {
// Call method
call_user_func(array($applicationInstance, $methodName));
- } // END - if
+ } // END - foreach
}
/**
@@ -380,7 +404,7 @@ final class FrameworkBootstrap {
} // END - if
// Initialize database layer
- $databaseInstance = ObjectFactory::createObjectByConfiguredName(FrameworkConfiguration::getSelfInstance()->getConfigEntry('database_type') . '_class');
+ $databaseInstance = ObjectFactory::createObjectByConfiguredName(self::getConfigurationInstance()->getConfigEntry('database_type') . '_class');
// Prepare database instance
$connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
@@ -462,25 +486,6 @@ final class FrameworkBootstrap {
return $success;
}
- /**
- * Detects the HTTPS flag
- *
- * @return $https The detected HTTPS flag or null if failed
- */
- public static function detectHttpSecured () {
- // Default is null
- $https = NULL;
-
- // Is HTTPS set?
- if (self::isHttpSecured()) {
- // Then use it
- $https = $_SERVER['HTTPS'];
- } // END - if
-
- // Return it
- return $https;
- }
-
/**
* Checks whether HTTPS is set in $_SERVER
*
@@ -507,7 +512,7 @@ final class FrameworkBootstrap {
} // END - if
// Construct the full URL and secure it against CSRF attacks
- $baseUrl = $protocol . '://' . self::detectDomain() . self::detectScriptPath();
+ $baseUrl = sprintf('%s://%s%s', $protocol, self::detectDomain(), self::detectScriptPath());
// Return the URL
return $baseUrl;
@@ -566,10 +571,10 @@ final class FrameworkBootstrap {
*/
private static function scanFrameworkClasses () {
// Include the class loader function
- require FrameworkConfiguration::getSelfInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
+ require self::getConfigurationInstance()->getConfigEntry('framework_base_path') . 'loader/class_ClassLoader.php';
// Register auto-load function with the SPL
- spl_autoload_register('CoreFramework\Loader\ClassLoader::autoLoad');
+ spl_autoload_register('Org\Mxchange\CoreFramework\Loader\ClassLoader::autoLoad');
// Scan for all framework classes, exceptions and interfaces
ClassLoader::scanFrameworkClasses();
@@ -587,7 +592,7 @@ final class FrameworkBootstrap {
$requestType = self::getRequestTypeFromSystem();
// Create a new request object
- $requestInstance = ObjectFactory::createObjectByName(sprintf('CoreFramework\Request\%sRequest', BaseFrameworkSystem::convertToClassName($request)));
+ $requestInstance = ObjectFactory::createObjectByName(sprintf('Org\Mxchange\CoreFramework\Request\%sRequest', BaseFrameworkSystem::convertToClassName($request)));
// Remember request instance here
self::setRequestInstance($requestInstance);
@@ -600,7 +605,7 @@ final class FrameworkBootstrap {
} // END - if
// ... and a new response object
- $responseClass = sprintf('CoreFramework\Response\%sResponse', BaseFrameworkSystem::convertToClassName($request));
+ $responseClass = sprintf('Org\Mxchange\CoreFramework\Response\%sResponse', BaseFrameworkSystem::convertToClassName($request));
$responseInstance = ObjectFactory::createObjectByName($responseClass);
// Remember response instance here
@@ -635,7 +640,7 @@ final class FrameworkBootstrap {
// Construct FQPN (Full-Qualified Path Name) for ApplicationHelper class
$applicationPath = sprintf(
'%s%s%s',
- FrameworkConfiguration::getSelfInstance()->getConfigEntry('application_base_path'),
+ self::getConfigurationInstance()->getConfigEntry('application_base_path'),
$application,
DIRECTORY_SEPARATOR
);
@@ -648,8 +653,8 @@ final class FrameworkBootstrap {
} // END - if
// Set the detected application's name and full path for later usage
- FrameworkConfiguration::getSelfInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
- FrameworkConfiguration::getSelfInstance()->setConfigEntry('detected_app_name' , $application);
+ self::getConfigurationInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
+ self::getConfigurationInstance()->setConfigEntry('detected_app_name' , $application);
}
/**
* Setter for request instance