From 03739dab08a3c99ecb781f37fee0fc24d0d059d5 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 22 Mar 2015 21:30:42 +0100 Subject: [PATCH] Minor improvements/fixes. Signed-off-by: Roland Haeder --- application/selector/exceptions.php | 12 +++++++----- application/selector/loader.php | 14 ++------------ application/selector/starter.php | 6 +++--- application/shipsimu/data.php | 2 +- application/shipsimu/exceptions.php | 4 ++-- application/shipsimu/loader.php | 14 ++------------ .../main/companies/class_ShippingCompany.php | 2 +- application/shipsimu/starter.php | 6 +++--- index.php | 4 ++-- 9 files changed, 23 insertions(+), 41 deletions(-) diff --git a/application/selector/exceptions.php b/application/selector/exceptions.php index d9cc8d9..1a93fc0 100644 --- a/application/selector/exceptions.php +++ b/application/selector/exceptions.php @@ -24,8 +24,8 @@ // Our own exception handler function __exceptionHandler (FrameworkException $e) { - // Call the app_die() method - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has terminated due to an uncaught exception: %s [%s]: %s Backtrace:
%s
", + // Call the app_exit() method + ApplicationEntryPoint::app_exit(sprintf('[Main:] The application %s (%s) has terminated due to an uncaught exception: %s [%s]: %s Backtrace:
%s
', ApplicationHelper::getSelfInstance()->getAppName(), ApplicationHelper::getSelfInstance()->getAppShortName(), $e->__toString(), @@ -44,7 +44,7 @@ set_exception_handler('__exceptionHandler'); // Error handler function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) { // Construct the message - $message = sprintf("File: %s, Line: %s, Code: %s, Message: %s", + $message = sprintf('File: %s, Line: %s, Code: %s, Message: %s', basename($errfile), $errline, $errno, @@ -61,10 +61,12 @@ set_error_handler('__errorHandler'); // Assertion handler function __assertHandler ($file, $line, $code) { // Empty code? - if ($code === "") $code = "Unknown"; + if (empty($code)) { + $code = 'Unknown'; + } // END - if // Create message - $message = sprintf("File: %s, Line: %s, Code: %s", + $message = sprintf('File: %s, Line: %s, Code: %s', basename($file), $line, $code diff --git a/application/selector/loader.php b/application/selector/loader.php index d28600b..bcb574f 100644 --- a/application/selector/loader.php +++ b/application/selector/loader.php @@ -22,18 +22,8 @@ * along with this program. If not, see . */ -// Get config instance -$cfg = FrameworkConfiguration::getSelfInstance(); - -// Load all classes for the application -foreach ($lowerClasses as $className) { - // Load the application classes - ClassLoader::getSelfInstance()->scanClassPath(sprintf("%s/%s/%s", $cfg->getConfigEntry('application_path'), $cfg->getConfigEntry('app_name'), $className)); -} // END - if - -// Clean up the global namespace -unset($lowerClasses); -unset($className); +// Scan for application's classes, exceptions and interfaces +ClassLoader::scanApplicationClasses(); // [EOF] ?> diff --git a/application/selector/starter.php b/application/selector/starter.php index 7ba3538..b6f4c45 100644 --- a/application/selector/starter.php +++ b/application/selector/starter.php @@ -29,18 +29,18 @@ $app = call_user_func_array(array(FrameworkConfiguration::getSelfInstance()->get // Some sanity checks if ((empty($app)) || (is_null($app))) { // Something went wrong! - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s could not be launched because the helper class %s is not loaded.", + ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because the helper class %s is not loaded.", $application, FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class') )); } elseif (!is_object($app)) { // No object! - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s could not be launched because 'app' is not an object.", + ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s 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_die(sprintf("[Main:] The application %s could not be launched because the method %s is missing.", + ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because the method %s is missing.", $application, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method') )); diff --git a/application/shipsimu/data.php b/application/shipsimu/data.php index efbb161..7b380c2 100644 --- a/application/shipsimu/data.php +++ b/application/shipsimu/data.php @@ -45,7 +45,7 @@ $app = call_user_func_array( // Set application name and version $app->setAppName('Ship-Simu Shipping Simulator'); $app->setAppVersion('0.0.0'); -$app->setAppShortName('shipsimu'); +$app->setAppShortName('ship_simu'); // [EOF] ?> diff --git a/application/shipsimu/exceptions.php b/application/shipsimu/exceptions.php index d9cc8d9..8e4e14f 100644 --- a/application/shipsimu/exceptions.php +++ b/application/shipsimu/exceptions.php @@ -24,8 +24,8 @@ // Our own exception handler function __exceptionHandler (FrameworkException $e) { - // Call the app_die() method - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s (%s) has terminated due to an uncaught exception: %s [%s]: %s Backtrace:
%s
", + // Call the app_exit() method + ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s (%s) has terminated due to an uncaught exception: %s [%s]: %s Backtrace:
%s
", ApplicationHelper::getSelfInstance()->getAppName(), ApplicationHelper::getSelfInstance()->getAppShortName(), $e->__toString(), diff --git a/application/shipsimu/loader.php b/application/shipsimu/loader.php index d28600b..bcb574f 100644 --- a/application/shipsimu/loader.php +++ b/application/shipsimu/loader.php @@ -22,18 +22,8 @@ * along with this program. If not, see . */ -// Get config instance -$cfg = FrameworkConfiguration::getSelfInstance(); - -// Load all classes for the application -foreach ($lowerClasses as $className) { - // Load the application classes - ClassLoader::getSelfInstance()->scanClassPath(sprintf("%s/%s/%s", $cfg->getConfigEntry('application_path'), $cfg->getConfigEntry('app_name'), $className)); -} // END - if - -// Clean up the global namespace -unset($lowerClasses); -unset($className); +// Scan for application's classes, exceptions and interfaces +ClassLoader::scanApplicationClasses(); // [EOF] ?> diff --git a/application/shipsimu/main/companies/class_ShippingCompany.php b/application/shipsimu/main/companies/class_ShippingCompany.php index de959b6..cee5ccc 100644 --- a/application/shipsimu/main/companies/class_ShippingCompany.php +++ b/application/shipsimu/main/companies/class_ShippingCompany.php @@ -582,7 +582,7 @@ class ShippingCompany extends BaseSimulator implements Customer, ContractPartner // As a customer the shippng company can withdraw from a contract public function withdrawFromContract (SignableContract $contractInstance) { - ApplicationEntryPoint::app_die("WITHDRAW:
".print_r($contractInstance, true)."
"); + ApplicationEntryPoint::app_exit("WITHDRAW:
".print_r($contractInstance, true)."
"); } // Get latest added contract instance diff --git a/application/shipsimu/starter.php b/application/shipsimu/starter.php index 7ba3538..b6f4c45 100644 --- a/application/shipsimu/starter.php +++ b/application/shipsimu/starter.php @@ -29,18 +29,18 @@ $app = call_user_func_array(array(FrameworkConfiguration::getSelfInstance()->get // Some sanity checks if ((empty($app)) || (is_null($app))) { // Something went wrong! - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s could not be launched because the helper class %s is not loaded.", + ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because the helper class %s is not loaded.", $application, FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class') )); } elseif (!is_object($app)) { // No object! - ApplicationEntryPoint::app_die(sprintf("[Main:] The application %s could not be launched because 'app' is not an object.", + ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s 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_die(sprintf("[Main:] The application %s could not be launched because the method %s is missing.", + ApplicationEntryPoint::app_exit(sprintf("[Main:] The application %s could not be launched because the method %s is missing.", $application, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method') )); diff --git a/index.php b/index.php index 14bb950..2870332 100644 --- a/index.php +++ b/index.php @@ -9,7 +9,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -55,7 +55,7 @@ final class ApplicationEntryPoint { // Is a message set? if (empty($message)) { // No message provided - $message = 'No message provided!'; + $message = 'No message provided.'; } // END - if // Get config instance -- 2.39.5