Implemented new config.core.php variables.

It is now possible to disable the modules and the events system using the config file. This will completely turn the system off.
The event system will still load the event classes but it will not send them around.
This commit is contained in:
Abel Hoogeveen 2016-05-15 15:37:26 +02:00
parent 9901ea55e7
commit be3c6c87ff
5 changed files with 23 additions and 12 deletions

View File

@ -1,7 +1,7 @@
<?php
return array(
'cache_path' => '',
'cache_file_path' => '',
'memcached' => array(
'default' => array(
'hostname' => '127.0.0.1',

View File

@ -2,6 +2,8 @@
return array(
'enable_composer' => true,
'enable_modules' => true,
'enable_events' => true,
'composer_autoloader' => '',
'registry_caching' => false,
'registry_caching_method' => 'file',

View File

@ -66,7 +66,7 @@ class FW_Cache_file extends FW_Driver {
Helpers::load('file');
Helpers::load('common');
$path = Config::get('cache')->cache_path;
$path = Config::get('cache')->cache_file_path;
$this->_cache_path = ($path === '') ? 'Application'.DS.'Cache/' : $path;
}

View File

@ -92,11 +92,14 @@ class Core
// And initialize the router paths
Router::init();
// Build all the registers for correct operation
Modules::buildRegister($config->registry_caching,
$config->registry_caching_method,
$config->registry_caching_time
);
// Build all the registers for correct operation, if modules are enabled
if ($config->enable_modules)
{
Modules::buildRegister($config->registry_caching,
$config->registry_caching_method,
$config->registry_caching_time
);
}
// Load Composer
if ($config->enable_composer) {
@ -104,6 +107,11 @@ class Core
self::loadComposer($file);
}
if (!$config->enable_events)
{
Events::disable();
}
// And fire the coreStartEvent
$event = Events::fireEvent('coreStartEvent');
if ($event->isCancelled()) {

View File

@ -183,8 +183,12 @@ class Events
return false;
}
Logger::newLevel("Firing Event: '".$eventName."'");
Logger::log('Initializing Event');
if (self::$enabled)
{
Logger::newLevel("Firing Event: '".$eventName."'");
Logger::log('Initializing Event');
}
if (func_num_args() > 1) {
call_user_func_array(array($event, 'init'), array_slice(func_get_args(), 1));
@ -192,9 +196,6 @@ class Events
// Do not run if the event system is disabled
if (!self::$enabled) {
Logger::log('Event system is disabled');
Logger::stopLevel();
return $event;
}