// Import framework stuff
use CoreFramework\Bootstrap\FrameworkBootstrap;
-use CoreFramework\Configuration\FrameworkConfiguration;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Loader\ClassLoader;
use CoreFramework\Manager\ManageableApplication;
*/
public function initApplication () {
// Get config instance
- $cfg = FrameworkConfiguration::getSelfInstance();
+ $cfg = FrameworkBootstrap::getConfigurationInstance();
// Initialize output system
self::createDebugInstance('ApplicationHelper');
<?php
// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Bootstrap\FrameworkBootstrap;
/**
* Configuration entries for this application only
*/
// Some hub-specific configuration like port hostname where we will listen, etc.
-$cfg = FrameworkConfiguration::getSelfInstance();
+$cfg = FrameworkBootstrap::getConfigurationInstance();
// CFG: DEFAULT-CONSOLE-COMMAND
$cfg->setConfigEntry('default_console_command', 'main');
*/
private static $responseInstance = NULL;
+ /**
+ * Instance of a FrameworkConfiguration class
+ */
+ private static $configurationInstance = NULL;
+
/*
* Includes applications may have. They will be tried in the given order,
* some will become soon deprecated.
// Prevent making instances from this "utilities" class
}
+ /**
+ * Some "getter" for a configuration instance, making sure, it is unique
+ *
+ * @return $configurationInstance An instance of a FrameworkConfiguration class
+ */
+ public static function getConfigurationInstance () {
+ // Is the instance there?
+ if (is_null(self::$configurationInstance)) {
+ // Init new instance
+ self::$configurationInstance = new FrameworkConfiguration();
+ } // END - if
+
+ // Return it
+ return self::$configurationInstance;
+ }
+
/**
* Getter for request instance
*
*/
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
*/
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(
} // 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);
*/
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');
// 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
);
} // 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
<?php
// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
use CoreFramework\Bootstrap\FrameworkBootstrap;
use CoreFramework\EntryPoint\ApplicationEntryPoint;
*/
// Get a new configuration instance
-$cfg = FrameworkConfiguration::getSelfInstance();
+$cfg = FrameworkBootstrap::getConfigurationInstance();
// CFG: ROOT-BASE-PATH
$cfg->setConfigEntry('root_base_path', ApplicationEntryPoint::getRootPath() . DIRECTORY_SEPARATOR);
* hard-coded configuration data and might be overwritten/extended by
* config data from the database.
*/
- private $config = array();
-
- /**
- * The configuration instance itself
- */
- private static $configInstance = NULL;
+ private static $config = array();
/**
* Call-back instance (unused)
const EXCEPTION_CONFIG_VALUE_TYPE_UNSUPPORTED = 0x132;
/**
- * Private constructor
+ * Default constructor, the configuration entries are static, not the
+ * whole instance.
*
* @return void
*/
- private function __construct () {
+ public function __construct () {
// Empty for now
}
return get_class($this);
}
- /**
- * Getter for a singleton instance of this class
- *
- * @return $configInstance A singleton instance of this class
- */
- public static final function getSelfInstance () {
- // is the instance there?
- if (is_null(self::$configInstance)) {
- // Create a config instance
- self::$configInstance = new FrameworkConfiguration();
- } // END - if
-
- // Return singleton instance
- return self::$configInstance;
- }
-
/**
* Checks whether the given configuration key is set
*
}
// Is it set?
- $isset = ((isset($this->config[$configKey])) || (array_key_exists($configKey, $this->config)));
+ $isset = ((isset(self::$config[$configKey])) || (array_key_exists($configKey, self::$config)));
// Return the result
return $isset;
} // END - if
// Return the requested value
- return $this->config[$configKey];
+ return self::$config[$configKey];
}
/**
// Set the configuration value
//* NOISY-DEBUG: */ print(__METHOD__ . ':configEntry=' . $configKey . ',configValue[' . gettype($configValue) . ']=' . $configValue . PHP_EOL);
- $this->config[$configKey] = $configValue;
+ self::$config[$configKey] = $configValue;
// Resort the array
- ksort($this->config);
+ ksort(self::$config);
}
/**
*/
public final function getConfigurationArray () {
// Return it
- return $this->config;
+ return self::$config;
}
/**
} // END - if
// Unset it
- unset($this->config[$configKey]);
+ unset(self::$config[$configKey]);
}
/**
$loaderInstance = self::getSelfInstance();
// Get config instance
- $configInstance = FrameworkConfiguration::getSelfInstance();
+ $configInstance = FrameworkBootstrap::getConfigurationInstance();
// Load all classes
foreach (self::$frameworkPaths as $shortPath) {
$loaderInstance = self::getSelfInstance();
// Get config instance
- $configInstance = FrameworkConfiguration::getSelfInstance();
+ $configInstance = FrameworkBootstrap::getConfigurationInstance();
// Load all classes for the application
foreach (self::$frameworkPaths as $shortPath) {
//* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
// Get config instance
- $configInstance = FrameworkConfiguration::getSelfInstance();
+ $configInstance = FrameworkBootstrap::getConfigurationInstance();
// Load all classes for the application
foreach (self::$testPaths as $shortPath) {
// Is the instance there?
if (is_null(self::$selfInstance)) {
// Get a new one
- self::$selfInstance = ClassLoader::createClassLoader(FrameworkConfiguration::getSelfInstance());
+ self::$selfInstance = ClassLoader::createClassLoader(FrameworkBootstrap::getConfigurationInstance());
} // END - if
// Return the instance
// Set configuration instance if no registry ...
if (!$this instanceof Register) {
// ... because registries doesn't need to be configured
- $this->setConfigInstance(FrameworkConfiguration::getSelfInstance());
+ $this->setConfigInstance(FrameworkBootstrap::getConfigurationInstance());
} // END - if
// Is the startup time set? (0 cannot be true anymore)
// Try it
try {
// Get a debugger instance
- $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_class'), $className);
+ $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_class'), $className);
} catch (NullPointerException $e) {
// Didn't work, no instance there
exit(sprintf('Cannot create debugInstance! Exception=%s,message=%s,className=%s,lineNumber=%d' . PHP_EOL, $e->__toString(), $e->getMessage(), $className, $lineNumber));
*/
protected static function createTempPathForFile (SplFileInfo $infoInstance) {
// Get config entry
- $basePath = FrameworkConfiguration::getSelfInstance()->getConfigEntry('temp_file_path');
+ $basePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('temp_file_path');
// Is the path writeable?
if (!is_writable($basePath)) {
namespace CoreFramework\Factory;
// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Bootstrap\FrameworkBootstrap;
use CoreFramework\Generic\EmptyVariableException;
use CoreFramework\Loader\NoClassException;
*/
public static final function createObjectByConfiguredName ($configEntry, array $args = array()) {
// Read the configuration entry
- $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($configEntry);
+ $className = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry);
// Send this to the other factory...
$objectInstance = self::createObjectByName($className, $args);
namespace CoreFramework\Factory\Stack;
// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Bootstrap\FrameworkBootstrap;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Registry\Registry;
public static final function createFileStackInstance ($prefix, $stackName) {
// Construct file stack name
$stackFileName = sprintf('%s%s/%s.%s',
- FrameworkConfiguration::getSelfInstance()->getConfigEntry('framework_base_path'),
- FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_file_stacks_path'),
+ FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('framework_base_path'),
+ FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('base_file_stacks_path'),
$stackName,
- FrameworkConfiguration::getSelfInstance()->getConfigEntry('file_stacks_extension')
+ FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('file_stacks_extension')
);
// If there is no handler?
namespace CoreFramework\Factory\User;
// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Bootstrap\FrameworkBootstrap;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Registry\Registry;
use CoreFramework\Request\Requestable;
// Probe on member instance
try {
// Get class name
- $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry('user_class');
+ $className = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('user_class');
// Try to instance it
$userInstance = call_user_func_array(array($className, 'createMemberByRequest'), array($requestInstance));
} catch (UnexpectedGuestAccountException $e) {
// Then try it with guest account
- $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry('guest_class');
+ $className = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('guest_class');
// Try to instance it
$userInstance = call_user_func_array(array($className, 'createGuestByRequest'), array($requestInstance));
namespace CoreFramework\Feature;
// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Bootstrap\FrameworkBootstrap;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Loader\NoClassException;
use CoreFramework\Object\BaseFrameworkSystem;
$configKey = sprintf('enable_feature_%s', $featureName);
// Check configuration
- self::$enabledFeatures[$featureName]['is_enabled'] = (FrameworkConfiguration::getSelfInstance()->getConfigEntry($configKey) === 'Y');
+ self::$enabledFeatures[$featureName]['is_enabled'] = (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configKey) === 'Y');
} // END - if
// Return "cached" status
namespace CoreFramework\Localization;
// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Bootstrap\FrameworkBootstrap;
use CoreFramework\Object\BaseFrameworkSystem;
use CoreFramework\Registry\Registerable;
use CoreFramework\Registry\Registry;
$langInstance->initLanguageStrings();
// Set language code from default config
- $langInstance->setLanguageCode(FrameworkConfiguration::getSelfInstance()->getConfigEntry('default_lang'));
+ $langInstance->setLanguageCode(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_lang'));
// Remember this instance
self::$selfInstance = $langInstance;
namespace CoreFramework\Output;
// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Bootstrap\FrameworkBootstrap;
use CoreFramework\Generic\UnsupportedOperationException;
use CoreFramework\Output\BaseOutput;
use CoreFramework\Stream\Output\OutputStreamer;
public static final function getInstance() {
// Is the self-instance already set?
if (is_null(self::$consoleInstance)) {
- $contentType = FrameworkConfiguration::getSelfInstance()->getConfigEntry('web_content_type');
+ $contentType = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('web_content_type');
self::$consoleInstance = ConsoleOutput::createConsoleOutput($contentType);
} // END - if
namespace CoreFramework\Console\Tools;
// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Bootstrap\FrameworkBootstrap;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Filesystem\FileNotFoundException;
use CoreFramework\Generic\FrameworkException;
parent::__construct(__CLASS__);
// Cache configuration entry
- self::$quietResolver = FrameworkConfiguration::getSelfInstance()->getConfigEntry('quiet_dns_resolver');
+ self::$quietResolver = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('quiet_dns_resolver');
}
/**
// Import framework stuff
use CoreFramework\Bootstrap\FrameworkBootstrap;
-use CoreFramework\Configuration\FrameworkConfiguration;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Filesystem\FileNotFoundException;
use CoreFramework\Helper\Application\ApplicationHelper;
} // END - if
// Get config instance
- $configInstance = FrameworkConfiguration::getSelfInstance();
+ $configInstance = FrameworkBootstrap::getConfigurationInstance();
// Do we have debug installation?
if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === true)) {
<?php
-
// Import needed stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Bootstrap\FrameworkBootstrap;
/*
* Copyright (C) 2017 Roland Haeder<roland@mxchange.org>
require dirname(__DIR__) . '/vendor/autoload.php';
// Quiet DNS resolver as this is not wanted here
-FrameworkConfiguration::getSelfInstance()->setConfigEntry('quiet_dns_resolver', TRUE);
+FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('quiet_dns_resolver', TRUE);
<?php
-
// Same namespace as target class
namespace CoreFramework\Configuration;
// Inport framework stuff
+use CoreFramework\Bootstrap\FrameworkBootstrap;
+use CoreFramework\Configuration\FrameworkConfiguration;
use CoreFramework\Loader\ClassLoader;
use CoreFramework\Generic\NullPointerException;
use CoreFramework\Generic\UnsupportedOperationException;
parent::setUpBeforeClass();
// Init instance
- self::$configInstance = FrameworkConfiguration::getSelfInstance();
+ self::$configInstance = FrameworkBootstrap::getConfigurationInstance();
/*
* Disable strict naming-convention check in own class loader, because
*/
public function testGettingSelfConfigInstance () {
// Get instance
- $dummyInstance = FrameworkConfiguration::getSelfInstance();
+ $dummyInstance = FrameworkBootstrap::getConfigurationInstance();
// Should be equal to own instance
$this->assertEquals(self::$configInstance, $dummyInstance);
*/
public function testEqualsConfigInstance () {
// Get instance
- $dummyInstance = FrameworkConfiguration::getSelfInstance();
+ $dummyInstance = new FrameworkConfiguration();
// Should return TRUE
$this->assertTrue(self::$configInstance->equals($dummyInstance));
*/
public function testHashCodeConfigInstance () {
// Get instance
- $dummyInstance = FrameworkConfiguration::getSelfInstance();
+ $dummyInstance = FrameworkBootstrap::getConfigurationInstance();
// Get hash code from both
$hashCodeExpected = self::$configInstance->hashCode();
*/
public function testSameConfigurationArrayGetter () {
// Get instance
- $dummyInstance = FrameworkConfiguration::getSelfInstance();
+ $dummyInstance = FrameworkBootstrap::getConfigurationInstance();
// Get it from both instances
$config1 = self::$configInstance->getConfigurationArray();