Changed Configurator boot process.

- Components are now initialized before deferredComponentClasses are called. This ensures that components are properly prepared to be called.
- Directories are now added to components before components are initialized.

The following order has thus been established:
3.1 Load Components
3.1.1 setInstance of component
3.1.2 run onCreateContainer()
3.2 Add directories by category
3.3 each component init()
3.4 deferComponentClass invoke

See document on FuzeWorks boot order.
This commit is contained in:
Abel Hoogeveen 2020-02-20 12:43:40 +01:00
parent c74967f2a2
commit 6f2e941eb1
No known key found for this signature in database
GPG Key ID: 96C2234920BF4292
5 changed files with 58 additions and 42 deletions

3
.gitattributes vendored
View File

@ -2,4 +2,5 @@
.gitignore export-ignore
.gitlab-ci.yml export-ignore
.travis.yml export-ignore
test/ export-ignore
test/ export-ignore
docs/ export-ignore

27
docs/boot.txt Normal file
View File

@ -0,0 +1,27 @@
FuzeWorks boot process
1.
1.1 Temp/Log directory set
1.2 Debug parameters set
2.
2.1 Define ENVIRONMENT
2.2 Core::init()
2.2.1 CWD Set
2.2.2 CoreDir set
2.2.3 Constants defined
2.2.4 shutdown/error/exception handlers set
2.3 new Factory()
2.3.1 new Config, Logger, Events, Libraries, Helpers, Plugins
3.
3.1 Load Components
3.1.1 setInstance of component
3.1.2 run onCreateContainer()
3.2 Add directories by category
3.3 each component init()
3.4 deferComponentClass invoke
4.
4.1 Factory::initFactory()
4.1.1 enable/disable Events
4.1.2 Plugins::loadHeadersFromPluginPaths()
4.1.3 coreStartEvent()
5. Return container

View File

@ -347,17 +347,18 @@ class Configurator
// Then prepare the debugger
$debug = ($this->parameters['debugEnabled'] && $this->parameters['debugMatch'] ? true : false);
// Then load the framework
$container = Core::init();
Logger::newLevel("Creating container...");
// Define environment constants
if ($debug == true)
{
define('ENVIRONMENT', 'DEVELOPMENT');
Logger::enable();
}
else
define('ENVIRONMENT', 'PRODUCTION');
// Load the Framework
$container = Core::init();
if ($debug)
Logger::enable();
Logger::newLevel("Creating container...");
// Load components
foreach ($this->components as $componentSuperClass => $component)
@ -381,6 +382,21 @@ class Configurator
$component->onCreateContainer($container);
}
// Add directories to Components
foreach ($this->directories as $component => $priorityArray)
{
Logger::logDebug("Adding directories for '" . $component . "'");
if (method_exists($container->{$component}, 'setDirectories'))
$container->{$component}->setDirectories($priorityArray);
}
// Initialize all components
foreach ($container as $component)
{
if (method_exists($component, 'init'))
$component->init();
}
// Invoke deferredComponentClass on FuzeWorks\Core classes
foreach ($this->deferredComponentClassMethods as $componentClass => $deferredComponentClasses)
{
@ -398,14 +414,6 @@ class Configurator
}
}
// Add directories to Components
foreach ($this->directories as $component => $priorityArray)
{
Logger::logDebug("Adding directories for '" . $component . "'");
if (method_exists($container->{$component}, 'setDirectories'))
$container->{$component}->setDirectories($priorityArray);
}
$container->initFactory();
Logger::stopLevel();
return $container;

View File

@ -170,13 +170,6 @@ class Factory
if (!$cfg->get('enable_events'))
Events::disable();
// Initialize all components
foreach ($this as $component)
{
if (method_exists($component, 'init'))
$component->init();
}
// Initialize all plugins
$this->plugins->loadHeadersFromPluginPaths();

View File

@ -533,35 +533,22 @@ class Logger {
public static function getType($type): string
{
switch ($type) {
case E_PARSE:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_STRICT:
case E_RECOVERABLE_ERROR:
case E_ERROR:
return 'ERROR';
case E_WARNING:
return 'WARNING';
case E_PARSE:
return 'ERROR';
case E_NOTICE:
return 'WARNING';
case E_CORE_ERROR:
return 'ERROR';
case E_CORE_WARNING:
return 'WARNING';
case E_COMPILE_ERROR:
return 'ERROR';
case E_COMPILE_WARNING:
return 'WARNING';
case E_USER_ERROR:
return 'ERROR';
case E_USER_WARNING:
return 'WARNING';
case E_USER_NOTICE:
return 'WARNING';
case E_USER_DEPRECATED:
return 'WARNING';
case E_STRICT:
return 'ERROR';
case E_RECOVERABLE_ERROR:
return 'ERROR';
case E_DEPRECATED:
case E_WARNING:
return 'WARNING';
}