*/
private static $configurationInstance = NULL;
+ /**
+ * Database instance
+ */
+ private static $databaseInstance = NULL;
+
/*
* Includes applications may have. They will be tried in the given order,
* some will become soon deprecated.
return self::$configurationInstance;
}
- /**
- * Getter for request instance
- *
- * @return $requestInstance An instance of a Requestable class
- */
- public static function getRequestInstance () {
- return self::$requestInstance;
- }
-
- /**
- * Getter for response instance
- *
- * @return $responseInstance An instance of a Responseable class
- */
- public static function getResponseInstance () {
- return self::$responseInstance;
- }
-
/**
* "Getter" to get response/request type from analysis of the system.
*
// Load basic include files to continue bootstrapping
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%sclasses%sutils%sclass_StringUtils.php', ApplicationEntryPoint::detectFrameworkPath(), DIRECTORY_SEPARATOR, 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)));
/*
* 3) Now, that there are all request parameters being available, check
- * if 'app' is supplied. If it is not found, abort execution, if
+ * if 'application' is supplied. If it is not found, abort execution, if
* found, continue below with next step.
*/
self::validateApplicationParameter();
));
}
- // Set it in registry
- GenericRegistry::getRegistry()->addInstance('application', $applicationInstance);
-
// Now call all methods in one go
foreach (array('setupApplicationData', 'initApplication', 'launchApplication') as $methodName) {
// Debug message
$applicationInstance = ApplicationHelper::getSelfInstance();
// Is the database instance already set?
- if ($applicationInstance instanceof DatabaseConnector) {
+ if (self::getDatabaseInstance() instanceof DatabaseConnector) {
// Yes, then abort here
throw new BadMethodCallException('Method called twice.');
} // END - if
$connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
// Set it in application helper
- $applicationInstance->setDatabaseInstance($connectionInstance);
+ self::setDatabaseInstance($connectionInstance);
}
/**
* @todo Test more fields
*/
public static function isHttpSecured () {
- return (isset($_SERVER['HTTPS']));
+ return (
+ (
+ (
+ isset($_SERVER['HTTPS'])
+ ) && (
+ strtolower($_SERVER['HTTPS']) == 'on'
+ )
+ ) || (
+ (
+ isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
+ ) && (
+ strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https'
+ )
+ )
+ );
}
/**
// Do we have HTTPS?
if (self::isHttpSecured()) {
// Add the >s< for HTTPS
- $protocol = 's';
+ $protocol = 'https';
} // END - if
// Construct the full URL and secure it against CSRF attacks
}
/**
- * 3) Validate parameter 'app' if it is set and the application is there.
+ * 3) Validate parameter 'application' if it is set and the application is there.
*
* @return void
*/
self::getConfigurationInstance()->setConfigEntry('detected_full_app_path', $applicationPath);
self::getConfigurationInstance()->setConfigEntry('detected_app_name' , $application);
}
+
+ /**
+ * Getter for request instance
+ *
+ * @return $requestInstance An instance of a Requestable class
+ */
+ public static function getRequestInstance () {
+ return self::$requestInstance;
+ }
+
+ /**
+ * Getter for response instance
+ *
+ * @return $responseInstance An instance of a Responseable class
+ */
+ public static function getResponseInstance () {
+ return self::$responseInstance;
+ }
+
/**
* Setter for request instance
*
self::$responseInstance = $responseInstance;
}
+ /**
+ * Setter for database instance
+ *
+ * @param $databaseInstance An instance of a DatabaseConnection class
+ * @return void
+ */
+ public static function setDatabaseInstance (DatabaseConnection $databaseInstance) {
+ self::$databaseInstance = $databaseInstance;
+ }
+
+ /**
+ * Getter for database instance
+ *
+ * @return $databaseInstance An instance of a DatabaseConnection class
+ */
+ public static function getDatabaseInstance () {
+ // Return instance
+ return self::$databaseInstance;
+ }
+
}