private static function installComponents($with_db = false) { $components = Component::getCoreComponents($with_db); if (!$components) { Backend::addError('Could not get components to pre install'); return false; } //Save original LogToFile setting $original = ConfigValue::get('LogToFile', false); $install_log_file = 'install_log_' . date('Ymd_His') . '.txt'; ConfigValue::set('LogToFile', $install_log_file); //Pre Install components Backend::addNotice(PHP_EOL . PHP_EOL . 'Installation started at ' . date('Y-m-d H:i:s')); $components = array_flatten($components, null, 'name'); foreach ($components as $component) { if (class_exists($component, true) && method_exists($component, 'pre_install')) { Backend::addNotice('Pre Installing ' . $component); if (!call_user_func_array(array($component, 'pre_install'), array())) { Backend::addError('Error on pre install for ' . $component); return false; } } } //Install Components foreach ($components as $component) { if (class_exists($component, true) && method_exists($component, 'install')) { Backend::addNotice('Installing ' . $component); if (!call_user_func_array(array($component, 'install'), array())) { Backend::addError('Error on installing ' . $component); return false; } } } //Install Application Components if (is_callable(array('Application', 'getComponents'))) { $app_components = Application::getComponents(); if (is_array($app_components)) { foreach ($components as $component) { if (class_exists($component, true) && method_exists($component, 'install')) { Backend::addNotice('Installing ' . $component); if (!call_user_func_array(array($component, 'install'), array())) { Backend::addError('Error on installing ' . $component); return false; } } } } } //Restore Original ConfigValue::set('LogToFile', $original); return true; }