// Initialize database layer
$databaseInstance = null;
-// Get config instance
-$cfg = FrameworkConfiguration::getInstance();
-
// Generate FQFN for the database layer
-$fqfn = $cfg->readConfig('base_path') . 'inc/database/lib-' . $cfg->readConfig('db_type') . '.php';
+$fqfn = FrameworkConfiguration::getInstance()->readConfig('base_path') . 'inc/database/lib-' . FrameworkConfiguration::getInstance()->readConfig('db_type') . '.php';
// Load the database layer include
if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) {
} else {
// Layer is missing!
ApplicationEntryPoint::app_die(sprintf("[Main:] Database layer is missing! (%s) -> R.I.P.",
- $cfg->readConfig('db_type')
+ FrameworkConfiguration::getInstance()->readConfig('db_type')
));
}
// Clean it up
-unset($fqfn, $cfg);
+unset($fqfn);
// Prepare database instance
$connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getInstance(), $databaseInstance);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Get config instance
-$cfg = FrameworkConfiguration::getInstance();
-
// Include the class loader function
-require($cfg->readConfig('base_path') . 'inc/loader/class_ClassLoader.php');
+require(FrameworkConfiguration::getInstance()->readConfig('base_path') . 'inc/loader/class_ClassLoader.php');
// Shall we include additional configs where you can configure some things? Then
// Load matching config
$application = trim($app[1]);
} else {
// Invalid entry found, first must be "app"!
- $application = $cfg->readConfig('default_application');
+ $application = FrameworkConfiguration::getInstance()->readConfig('default_application');
}
} else {
// Set the "application selector" application
- $application = $cfg->readConfig('default_application');
+ $application = FrameworkConfiguration::getInstance()->readConfig('default_application');
}
// Secure it, by keeping out tags
$application = preg_replace('/([^a-z0-9_-])+/i', '', $application);
// Set the application name for later usage
-$cfg->setConfigEntry('app_name', $application);
+FrameworkConfiguration::getInstance()->setConfigEntry('app_name', $application);
// Register auto-load function with the SPL
spl_autoload_register('ClassLoader::autoLoad');
/**
* Is the devel package included?
*/
-if (is_dir($cfg->readConfig('base_path') . "devel")) {
+if (is_dir(FrameworkConfiguration::getInstance()->readConfig('base_path') . "devel")) {
/**
* Load all development includes
*/
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Get config instance
-$cfg = FrameworkConfiguration::getInstance();
-
// Try to load these includes in the given order
$configAppIncludes = array(
- 'class_' . $cfg->readConfig('app_helper_class'), // The ApplicationHelper class
+ 'class_' . FrameworkConfiguration::getInstance()->readConfig('app_helper_class'), // The ApplicationHelper class
'config', // The application's own configuration
'data', // Application data
'init', // The application initializer
}
// Generate a FQFN for the helper class
- $fqfn = $cfg->readConfig('application_path') . $cfg->readConfig('app_name') . '/' . $inc . '.php';
+ $fqfn = FrameworkConfiguration::getInstance()->readConfig('application_path') . FrameworkConfiguration::getInstance()->readConfig('app_name') . '/' . $inc . '.php';
// Does the include file exists?
if ((file_exists($fqfn)) && (is_file($fqfn)) && (is_readable($fqfn))) {
// Load it
require_once($fqfn);
- } elseif ($cfg->readConfig('verbose_level') > 0) {
+ } elseif (FrameworkConfiguration::getInstance()->readConfig('verbose_level') > 0) {
// File is missing
trigger_error(sprintf("Cannot load application script %s.php! File is missing or read-protected.",
$inc
}
// Remove variables from namespace, which we don't need
-unset($cfg, $inc, $configAppIncludes, $fqfn);
+unset($inc, $configAppIncludes, $fqfn);
// [EOF]
?>
// Now try the test
$testPassed = false;
try {
- // Get a configuration instance
- $cfg = FrameworkConfiguration::getInstance();
-
// Now find a configuration variable that does not exist
- $dummy = $cfg->readConfig('does_not_exist');
+ $dummy = FrameworkConfiguration::getInstance()->readConfig('does_not_exist');
} catch (ConfigEntryNotFoundException $expected) {
// This exception was expected, so it is fine
$testPassed = true;
// Now try the test
$testPassed = false;
try {
- // Get a configuration instance
- $cfg = FrameworkConfiguration::getInstance();
-
// Try to read an empty configuration variable
- $dummy = $cfg->readConfig('');
+ $dummy = FrameworkConfiguration::getInstance()->readConfig('');
} catch (ConfigEntryIsEmptyException $expected) {
// This exception was expected, so it is fine
$testPassed = true;
// Now try the test
$testPassed = false;
try {
- // Get a configuration instance
- $cfg = FrameworkConfiguration::getInstance();
-
// Try to read an empty configuration variable
- $cfg->setConfigEntry('', 'will_never_be_set');
+ FrameworkConfiguration::getInstance()->setConfigEntry('', 'will_never_be_set');
} catch (ConfigEntryIsEmptyException $expected) {
// This exception was expected, so it is fine
$testPassed = true;
// Try it here
$value = "This is a test value";
try {
- // Get a configuration instance
- $cfg = FrameworkConfiguration::getInstance();
-
// Try to read an empty configuration variable
- $cfg->setConfigEntry('test_key', "{$value}");
+ FrameworkConfiguration::getInstance()->setConfigEntry('test_key', "{$value}");
// Read the config entry we have just written
- $readValue = $cfg->readConfig('test_key');
+ $readValue = FrameworkConfiguration::getInstance()->readConfig('test_key');
// Now test the values
$this->assertEquals($value, $readValue);