<?php
+// Must be this namespace, else the launcher cannot find the class.
+namespace CoreFramework\Helper\Application;
+
+// Import framework stuff
+use CoreFramework\Bootstrap\FrameworkBootstrap;
+use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Loader\ClassLoader;
+use CoreFramework\Manager\ManageableApplication;
+use CoreFramework\Object\BaseFrameworkSystem;
+use CoreFramework\Registry\Registerable;
+use CoreFramework\Registry\Registry;
+use CoreFramework\Template\CompileableTemplate;
+
/**
* A class holding general data about the application and some methods for
* the management including the entry point.
}
/**
- * Launches the hub system
+ * 1) Setups application data
*
* @return void
*/
- public final function entryPoint () {
- // Set this application in registry
- Registry::getRegistry()->addInstance('app', $this);
-
- // Is no external address set?
- if ($this->getConfigInstance()->getConfigEntry('external_address') == '') {
- // Determine external address
- $this->getConfigInstance()->setConfigEntry('external_address', HubTools::determineOwnExternalAddress());
- } // END - if
-
- // Default response is console
- $response = self::getResponseTypeFromSystem();
- $responseType = self::getResponseTypeFromSystem();
+ public function setupApplicationData () {
+ // Set all application data
+ $this->setAppName('Unit tests and more');
+ $this->setAppVersion('0.0.0');
+ $this->setAppShortName('tests');
+ }
- // Create a new request object
- $requestInstance = ObjectFactory::createObjectByName(self::convertToClassName($response) . 'Request');
+ /**
+ * 2) Does initial stuff before starting the application
+ *
+ * @return void
+ */
+ public function initApplication () {
+ // Get config instance
+ $cfg = FrameworkConfiguration::getSelfInstance();
- // Remember request instance here
- $this->setRequestInstance($requestInstance);
+ // Initialize output system
+ ApplicationHelper::createDebugInstance('ApplicationHelper');
- // Do we have another response?
- if ($requestInstance->isRequestElementSet('request')) {
- // Then use it
- $response = strtolower($requestInstance->getRequestElement('request'));
- $responseType = $response;
- } // END - if
+ /*
+ * This application needs a database connection then simply call init
+ * method.
+ */
+ FrameworkBootstrap::initDatabaseInstance();
- // ... and a new response object
- $responseClass = sprintf('%sResponse', self::convertToClassName($response));
- $responseInstance = ObjectFactory::createObjectByName($responseClass, array($this));
+ // Get own internal address and set it in config
+ $cfg->setConfigEntry('internal_address', HubTools::determineOwnInternalAddress());
+ }
- // Remember response instance here
- $this->setResponseInstance($responseInstance);
+ /**
+ * 3) Launches the application
+ *
+ * @return void
+ */
+ public function launchApplication () {
+ // Get request/response instances
+ $requestInstance = FrameworkBootstrap::getRequestInstance();
+ $responseInstance = FrameworkBootstrap::getResponseInstance();
// Get the parameter from the request
$commandName = $requestInstance->getRequestElement('command');
return 'node_main';
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\AptProxy;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general NodeAptProxy class
*
return $this->isActive;
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\Block;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general Block class
*
<?php
+// Own namespace
+namespace Hub\Chat;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general NodeChat class
*
return $this->isActive;
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\Generic;
+
/**
* A general hub system class
*
return $this->getConfigInstance()->getConfigEntry('session_id');
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\Communicator;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general communicator class
*
<?php
+// Own namespace
+namespace Hub\Network\Package;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A NetworkPackageCompressor decorator class. This decorator can later be
* easily extended without changing any other code.
<?php
+// Own namespace
+namespace Hub\Crawler;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general NodeCrawler class
*
<?php
+// Own namespace
+namespace Hub\Cruncher;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general hub cruncher class
*
return;
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\Decoder;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general Decoder class
*
<?php
+// Own namespace
+namespace Hub\Dht;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general DHT class
*
<?php
+// Own namespace
+namespace Hub\Node\Dht;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A Node DHT facade class
*
parent::__construct($className);
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\Network\Discovery\Socket;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A socket discovery class
*
<?php
+// Own namespace
+namespace Hub\Handler\Node\Message\Announcement;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A NodeMessageAnnouncement handler
*
<?php
+// Own namespace
+namespace Hub\Handler\Message;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general message handler, this class must be abstract to make the template
* method pattern working.
<?php
+// Own namespace
+namespace Hub\Helper;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general hub helper class. This class does not extend BaseHelper.
*
// Return it
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\Helper\Dht\Bootstrap;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A Bootstrap Dht helper class
*
<?php
+// Own namespace
+namespace Hub\Helper\Dht\Publish;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A PublishingEntry Dht helper class
*
<?php
+// Own namespace
+namespace Hub\Helper\Node;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general node helper class
*
<?php
+// Own namespace
+namespace Hub\Information;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general Info class
*
return $menuInstance;
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\Miner;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general hub miner class
*
<?php
+// Own namespace
+namespace Hub\Node;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general hub node class
*
} // END - foreac
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\Network\Package\Assembler;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A PackageAssembler class to assemble a package content stream fragemented
* by PackageFragmenter back to a raw package data array.
<?php
+// Own namespace
+namespace Hub\Network\Package;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A NetworkPackage class. This class implements Deliverable and Receivable
* because all network packages should be deliverable to other nodes and
<?php
+// Own namespace
+namespace Hub\Network\Package\Fragment;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A PackageFragmenter class to fragment package data into smaller chunks for
* delivery. This class calculates a final hash on the raw input data and
<?php
+// Own namespace
+namespace Hub\Pool;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general pool class
*
return $isValid;
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\Receipt;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general Recipient class
*
<?php
+// Own namespace
+namespace Hub\Network\Receipt\Upper;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A Upper recipient
*
<?php
+// Own namespace
+namespace Hub\Resolver\Protocol;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A generic protocol resolver class
*
<?php
+// Own namespace
+namespace Hub\Scanner;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general Scanner class
*
<?php
+// Own namespace
+namespace Hub\Source;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general Source class
*
<?php
+// Own namespace
+namespace Hub\Helper\Connection;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A helper class for maintaining connection statistics, no instance is
* required to use this class.
<?php
+// Own namespace
+namespace Hub\Stream\Input\Raw;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A class for handling incoming (encoded) raw data with start and end markers.
* The "stream" is being verified by its length (if modulo 4 of it is always
<?php
+// Own namespace
+namespace Hub\Tag;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* A general Tags class
*
call_user_func_array(array($this, $methodName), array());
}
}
-
-// [EOF]
-?>
<?php
+// Own namespace
+namespace Hub\Tools;
+
+// Import hub-specific stuff
+use Hub\Generic\BaseHubSystem;
+
/**
* This class contains static helper functions for our hub
*
<?php
+// Import framework stuff
+use CoreFramework\Configuration\FrameworkConfiguration;
+
/**
* Local configuration entries which you can customize. Please keep the
* comments starting with CFG: as-is or else, the later configuration wizard
<?php
+// Import framework stuff
+use CoreFramework\Configuration\FrameworkConfiguration;
+
/**
* Configuration entries for this application only
*
// CFG: ENABLE-FEATURE-FUSE
$cfg->setConfigEntry('enable_feature_fuse', 'N');
-
-// [EOF]
-?>
<?php
-/**
- * Application data
- *
- * Please remember that this include file is being loaded *before* the class
- * loader is loading classes from "exceptions", "interfaces" and "main"!
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// Get config instance
-$cfg = FrameworkConfiguration::getSelfInstance();
-
-// Get an instance of the helper
-$app = call_user_func_array(
- array($cfg->getConfigEntry('app_helper_class'), 'getSelfInstance'),
- array()
-);
-
-// Set application name and version
-$app->setAppName('Generic Object Sharing Hub');
-$app->setAppVersion('0.0.0');
-$app->setAppShortName('hub');
-
-// [EOF]
-?>
+// @DEPRECATED
// Set error reporting
error_reporting(E_ALL | E_STRICT);
-
-// [EOF]
-?>
<?php
+// Import framework stuff
+use CoreFramework\Generic\FrameworkException;
+use CoreFramework\Object\BaseFrameworkSystem;
+
/**
- * An include file for setting up the exception handler of the hub
+ * An include file for setting up the exception handler of test suite
*
* @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
// The node's own exception handler
function hub_exception_handler ($exceptionInstance) {
// Is it an object and a valid instance?
- if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof FrameworkException)) {
+ if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof Exception)) {
// Init variable
$backTrace = '';
// Init argument string
$argsString = '';
- // Any arguments?
- if ((isset($traceArray['args'])) && (is_array($traceArray['args'])) && (count($traceArray['args']) > 0)) {
- // Convert arguments type into human-readable
- foreach ($traceArray['args'] as $arg) {
- $argsString .= ', ' . gettype($arg);
- } // END - foreach
- $argsString = substr($argsString, 2);
- } // END - if
+ // Convert arguments type into human-readable
+ foreach ($traceArray['args'] as $arg) {
+ $argsString .= ', ' . gettype($arg);
+ } // END - foreach
+ $argsString = substr($argsString, 2);
// Set missing file/line
if (!isset($traceArray['file'])) $traceArray['file'] = 'unknown';
--------------------------------------------------------------------------------
%s
--------------------------------------------------------------------------------\n",
- trim(html_entity_decode(strip_tags($exceptionInstance->__toString()))),
+ trim(html_entity_decode(strip_tags(get_class($exceptionInstance)))),
trim(html_entity_decode(strip_tags($exceptionInstance->getMessage()))),
- $exceptionInstance->getHexCode(),
+ ($exceptionInstance instanceof FrameworkException ? $exceptionInstance->getHexCode() : '0x' . bin2hex($exceptionInstance->getCode())),
$exceptionInstance->getFile(),
$exceptionInstance->getLine(),
trim($backTrace)
// Output the message
print($message);
+ } elseif (is_object($exceptionInstance)) {
+ // Output more details
+ printf('exceptionInstance=%s', print_r($exceptionInstance, true));
} else {
/*
* Invalid exception instance detected! Do *only* throw exceptions that
* extends our own exception 'FrameworkException' to get such nice
* outputs like above.
*/
- print('exceptionInstance[]=' . gettype($exceptionInstance) . ' is invalid! Please inform the core developer team.');
+ printf('exceptionInstance[]=%s is invalid! Please inform the core developer team.' . PHP_EOL, gettype($exceptionInstance));
}
}
// Error handler
-function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) {
+function hub_error_handler ($errno, $errstr, $errfile, $errline, array $errcontext) {
// Construct the message
$message = sprintf('File: %s, Line: %s, Code: %s, Message: %s',
basename($errfile),
} // END - function
// Assertion handler
-function __assertHandler ($file, $line, $code) {
+function hub_assert_handler ($file, $line, $code) {
// Empty code?
if ($code === '') {
$code = '<em>Unknown</em>';
);
// Log assert
- die($message . PHP_EOL);
syslog(LOG_WARNING, $message);
// Throw an exception here
} // END - function
// Set error handler
-//set_error_handler('__errorHandler');
+//set_error_handler('hub_error_handler');
-// Set the exception handler
+// Set the new handler
set_exception_handler('hub_exception_handler');
// Init assert handling
-assert_options(ASSERT_ACTIVE , TRUE);
-assert_options(ASSERT_WARNING , FALSE);
-assert_options(ASSERT_BAIL , TRUE);
-assert_options(ASSERT_QUIET_EVAL, FALSE);
-
-// Set assertion handler
-assert_options(ASSERT_CALLBACK , '__assertHandler');
-
-// [EOF]
-?>
+assert_options(ASSERT_ACTIVE , true);
+assert_options(ASSERT_WARNING , false);
+assert_options(ASSERT_BAIL , true);
+assert_options(ASSERT_QUIET_EVAL, false);
+assert_options(ASSERT_CALLBACK , 'hub_assert_handler');
<?php
-/**
- * Application initializer
- *
- * Please remember that this include file is being loaded *before* the class
- * loader is loading classes from "exceptions", "interfaces" and "main"!
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// Get config instance
-$cfg = FrameworkConfiguration::getSelfInstance();
-
-// Initialize output system
-ApplicationHelper::createDebugInstance('ApplicationHelper');
-
-// This application needs a database connection then we have to simply include
-// the inc/database.php script
-require($cfg->getConfigEntry('base_path') . 'inc/database.php');
-
-// Get own internal address and set it in config
-$cfg->setConfigEntry('internal_address', HubTools::determineOwnInternalAddress());
-
-// [EOF]
-?>
+// @DEPRECATED
<?php
-/**
- * The application's class loader
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// Scan for application's classes, exceptions and interfaces
-ClassLoader::scanApplicationClasses();
-
-// [EOF]
-?>
+// @DEPRECATED
<?php
-/**
- * The application launcher
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// Is there an application helper instance? We need the method main() for
-// maining the application
-$app = call_user_func_array(
- array(
- FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class'), 'getSelfInstance'
- ), array()
-);
-
-// Some sanity checks
-if ((empty($app)) || (is_null($app))) {
- // Something went wrong!
- ApplicationEntryPoint::app_exit(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the helper class <span class="class_name">%s</span> is not loaded.',
- $application,
- FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class')
- ));
-} elseif (!is_object($app)) {
- // No object!
- ApplicationEntryPoint::app_exit(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because 'app' is not an object.',
- $application
- ));
-} elseif (!method_exists($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method'))) {
- // Method not found!
- ApplicationEntryPoint::app_exit(sprintf('[Main:] The application <span class="app_name">%s</span> could not be launched because the method <span class="method_name">%s</span> is missing.',
- $application,
- FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')
- ));
-}
-
-// Call user function
-call_user_func_array(array($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method')), array());
-
-// [EOF]
-?>
+// @DEPRECATED
// close the listening socket
socket_close($main_sock);
-
-?>
print 'Result from mhash() benchmark (in seconds per hasher):' . "\r\n";
print_r($timers) . "\n";
-
-?>
out(__FILE__, __LINE__, 'MIN/AVG/MAX=' . $min . '/' . $avg . '/' . $max . '');
out(__FILE__, __LINE__, 'INVALID=' . $invalid . '');
out(__FILE__, __LINE__, 'FAILED=' . $failed . '');
-
-?>
$GLOBALS['last_message'] = $message;
}
}
-
-?>
// Sleep a little
if (function_exists('time_nanosleep')) time_nanosleep(0, 500000);
} while ($pkt !== FALSE);
-
-?>
-Subproject commit 1893995b39b02c07012c5f3795654fb9251b5ebd
+Subproject commit afe4936b8a55f38736e1af5191a964a926d7255a
+++ /dev/null
-core/inc/
\ No newline at end of file
<?php
+// Own namespace (watch out: core)
+namespace CoreFramework\EntryPoint;
+
+// Import framework stuff
+use CoreFramework\Bootstrap\FrameworkBootstrap;
+use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Helper\Application\ApplicationHelper;
+use CoreFramework\Localization\LanguageSystem;
+use CoreFramework\Loader\ClassLoader;
+use CoreFramework\Generic\FrameworkException;
+
+// Import SPL stuff
+use \Exception;
+
/**
* The main class with the entry point to the whole application. This class
* "emulates" Java's entry point call. Additionally it covers local
*/
final class ApplicationEntryPoint {
/**
- * Core path
+ * Framework path
*/
- private static $corePath = '';
+ private static $frameworkPath = '';
/**
* The application's emergency exit
* @return void
* @todo This method is old code and needs heavy rewrite and should be moved to ApplicationHelper
*/
- public static final function app_exit ($message = '', $code = FALSE, $extraData = '', $silentMode = FALSE) {
+ public static final function app_exit ($message = '', $code = false, $extraData = '', $silentMode = false) {
// Is this method already called?
if (isset($GLOBALS['app_die_called'])) {
// Then output the text directly
} // END - if
// This method shall not be called twice
- $GLOBALS['app_die_called'] = TRUE;
+ $GLOBALS['app_die_called'] = true;
// Is a message set?
if (empty($message)) {
$configInstance = FrameworkConfiguration::getSelfInstance();
// Do we have debug installation?
- if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === TRUE)) {
+ if (($configInstance->getConfigEntry('product_install_mode') == 'productive') || ($silentMode === true)) {
// Abort here
exit();
} // END - if
// Get some instances
- $tpl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('html_template_class');
+ $tpl = $configInstance->getConfigEntry('html_template_class');
$languageInstance = LanguageSystem::getSelfInstance();
// Initialize template instance here to avoid warnings in IDE
// Get the template instance from our object factory
$templateInstance = ObjectFactory::createObjectByName($tpl);
} catch (FrameworkException $e) {
- exit(sprintf("[Main:] Could not initialize template engine for reason: <span class=\"exception_reason\">%s</span>",
+ exit(sprintf('[Main:] Could not initialize template engine for reason: <span class="exception_reason">%s</span>',
$e->getMessage()
));
}
} // END - if
// Add the traceback path to the final output
- $backtrace .= sprintf("<span class=\"backtrace_file\">%s</span>:%d, <span class=\"backtrace_function\">%s(%d)</span><br />\n",
+ $backtrace .= sprintf('<span class="backtrace_file">%s</span>:%d, <span class="backtrace_function">%s(%d)</span><br />' . PHP_EOL,
basename($trace['file']),
$trace['line'],
$trace['function'],
$applicationInstance = NULL;
// Is the class there?
- if (class_exists('ApplicationHelper')) {
+ if (class_exists('CoreFramework\Helper\Application\ApplicationHelper')) {
// Get application instance
$applicationInstance = ApplicationHelper::getSelfInstance();
}
/**
- * Determines the correct absolute path for all includes only once per run.
- * Other calls of this method are being "cached".
+ * Determines the correct absolute path for the framework. A set of common
+ * paths is being tested (first most common for applications, second when
+ * core tests are being executed and third/forth if the framework has been
+ * cloned there).
*
- * @return $corePath Base path (core) for all includes
+ * @return $frameworkPath Path for framework
*/
- protected static final function detectCorePath () {
+ public static final function detectFrameworkPath () {
// Is it not set?
- if (empty(self::$corePath)) {
- // Auto-detect our core path
- self::$corePath = str_replace("\\", '/', dirname(__FILE__));
+ if (empty(self::$frameworkPath)) {
+ // Auto-detect core path (first application-common)
+ foreach (array('core', '.', '/usr/local/share/php/core', '/usr/share/php/core') as $possiblePath) {
+ // Create full path for testing
+ $realPath = realpath($possiblePath);
+
+ // Debug message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: realPath[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($realPath), $realPath);
+
+ // Is it false?
+ if ($realPath === false) {
+ // Then, not found.
+ continue;
+ } // END - if
+
+ // First create full-qualified file name (FQFN) to framework/config-global.php
+ $fqfn = sprintf(
+ '%s%sframework%sconfig-global.php',
+ $realPath,
+ DIRECTORY_SEPARATOR,
+ DIRECTORY_SEPARATOR,
+ $possiblePath
+ );
+
+ // Debug message
+ //* NOISY-DEBUG: */ printf('[%s:%d]: fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fqfn);
+
+ // Is it readable?
+ if (is_readable($fqfn)) {
+ // Found one
+ self::$frameworkPath = $realPath . '/framework/';
+
+ // Abort here
+ break;
+ } // END - if
+ } // END - foreach
+
+ // Able to find?
+ if (!is_dir(self::$frameworkPath)) {
+ // Is no directory
+ throw new Exception('Cannot find framework.');
+ } // END - if
} // END - if
// Return it
- return self::$corePath;
+ return self::$frameworkPath;
}
/**
- * The application's main entry point. This class isolates some local
+ * Getter for root path
+ *
+ * @return $rootPath Root path
+ */
+ public static function getRootPath () {
+ // Get __DIR__, really simple and no detection
+ return __DIR__;
+ }
+
+ /**
+ * The framework's main entry point. This class isolates some local
* variables which shall not become visible to outside because of security
- * concerns. We are doing this here to "emulate" the well-known entry
- * point in Java.
+ * concerns. This is done here to "emulate" the well-known entry point in
+ * Java.
*
* @return void
*/
public static final function main () {
- // Load config file
- require(self::detectCorePath() . '/inc/config.php');
+ // Load bootstrap file
+ require sprintf('%sbootstrap%sbootstrap.inc.php', self::detectFrameworkPath(), DIRECTORY_SEPARATOR);
- // Load all include files
- require($cfg->getConfigEntry('base_path') . 'inc/includes.php');
+ /*
+ * Initial bootstrap is done, continue with initialization of
+ * framework.
+ */
+ FrameworkBootstrap::initFramework();
- // Include the application selector
- require($cfg->getConfigEntry('base_path') . 'inc/selector.php');
- } // END - main()
-} // END - class
+ // Next initialize the detected application
+ FrameworkBootstrap::prepareApplication();
+
+ /*
+ * Last step is to start the application, this will also initialize and
+ * register the application instance in registry.
+ */
+ FrameworkBootstrap::startApplication();
+ }
+}
// Developer mode active? Comment out if no dev!
-define('DEVELOPER', TRUE);
+define('DEVELOPER', true);
// Log all exceptions (only debug! This option can create large error logs)
-//define('LOG_EXCEPTIONS', TRUE);
+//define('LOG_EXCEPTIONS', true);
//xdebug_start_trace();
-// Do not remove the following line:
+// Call above main() method
ApplicationEntryPoint::main();
-
-// [EOF]
-?>