Minor improvements/fixes.
authorRoland Haeder <roland@mxchange.org>
Sun, 22 Mar 2015 20:30:42 +0000 (21:30 +0100)
committerRoland Haeder <roland@mxchange.org>
Sun, 22 Mar 2015 20:30:42 +0000 (21:30 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/selector/exceptions.php
application/selector/loader.php
application/selector/starter.php
application/shipsimu/data.php
application/shipsimu/exceptions.php
application/shipsimu/loader.php
application/shipsimu/main/companies/class_ShippingCompany.php
application/shipsimu/starter.php
index.php

index d9cc8d9e6d90aa6aa8b1d58895c6f2d6cc103505..1a93fc0f40263b94ede8938f1417f1f96b738bb6 100644 (file)
@@ -24,8 +24,8 @@
 
 // Our own exception handler
 function __exceptionHandler (FrameworkException $e) {
-       // Call the app_die() method
-       ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> (<span class=\"app_short_name\">%s</span>) has terminated due to an uncaught exception: <span class=\"exception_name\">%s</span> <span class=\"exception_number\">[%s]</span>: <span class=\"debug_exception\">%s</span> Backtrace: <div class=\"debug_backtrace\">%s</div>",
+       // Call the app_exit() method
+       ApplicationEntryPoint::app_exit(sprintf('[Main:] The application <span class="app_name">%s</span> (<span class="app_short_name">%s</span>) has terminated due to an uncaught exception: <span class="exception_name">%s</span> <span class="exception_number">[%s]</span>: <span class="debug_exception">%s</span> Backtrace: <div class="debug_backtrace">%s</div>',
                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: <span class=\"debug_file\">%s</span>, Line: <span class=\"debug_line\">%s</span>, Code: <span class=\"debug_code\">%s</span>, Message: <span class=\"debug_message\">%s</span>",
+       $message = sprintf('File: <span class="debug_file">%s</span>, Line: <span class="debug_line">%s</span>, Code: <span class="debug_code">%s</span>, Message: <span class="debug_message">%s</span>',
                basename($errfile),
                $errline,
                $errno,
@@ -61,10 +61,12 @@ set_error_handler('__errorHandler');
 // Assertion handler
 function __assertHandler ($file, $line, $code) {
        // Empty code?
-       if ($code === "") $code = "<em>Unknown</em>";
+       if (empty($code)) {
+               $code = '<em>Unknown</em>';
+       } // END - if
 
        // Create message
-       $message = sprintf("File: <span class=\"debug_file\">%s</span>, Line: <span class=\"debug_line\">%s</span>, Code: <span class=\"debug_code\">%s</span>",
+       $message = sprintf('File: <span class="debug_file">%s</span>, Line: <span class="debug_line">%s</span>, Code: <span class="debug_code">%s</span>',
                basename($file),
                $line,
                $code
index d28600b837e069b16a7f0694c3e898acb8d43bc5..bcb574f8154d52f5a3975cfac3ff08a8354d172f 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-// 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]
 ?>
index 7ba35384094554a53b00fe32e6a87e9f4b2cd74e..b6f4c45f5ba09ab297eaeb037510b7ae3e546ac4 100644 (file)
@@ -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 <span class=\"app_name\">%s</span> could not be launched because the helper class <span class=\"class_name\">%s</span> is not loaded.",
+       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_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; is not an object.",
+       ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; is not an object.",
                $application
        ));
 } elseif (!method_exists($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method'))) {
        // Method not found!
-       ApplicationEntryPoint::app_die(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.",
+       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')
        ));
index efbb1617e9337c0278c9855e17395f7b27447626..7b380c2c3ab83483ebdb0b4c145c8ef4bae33b5e 100644 (file)
@@ -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]
 ?>
index d9cc8d9e6d90aa6aa8b1d58895c6f2d6cc103505..8e4e14ff95c40d770bfdbf11176425225b50392c 100644 (file)
@@ -24,8 +24,8 @@
 
 // Our own exception handler
 function __exceptionHandler (FrameworkException $e) {
-       // Call the app_die() method
-       ApplicationEntryPoint::app_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> (<span class=\"app_short_name\">%s</span>) has terminated due to an uncaught exception: <span class=\"exception_name\">%s</span> <span class=\"exception_number\">[%s]</span>: <span class=\"debug_exception\">%s</span> Backtrace: <div class=\"debug_backtrace\">%s</div>",
+       // Call the app_exit() method
+       ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> (<span class=\"app_short_name\">%s</span>) has terminated due to an uncaught exception: <span class=\"exception_name\">%s</span> <span class=\"exception_number\">[%s]</span>: <span class=\"debug_exception\">%s</span> Backtrace: <div class=\"debug_backtrace\">%s</div>",
                ApplicationHelper::getSelfInstance()->getAppName(),
                ApplicationHelper::getSelfInstance()->getAppShortName(),
                $e->__toString(),
index d28600b837e069b16a7f0694c3e898acb8d43bc5..bcb574f8154d52f5a3975cfac3ff08a8354d172f 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-// 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]
 ?>
index de959b62f836e6f272d9de6d6e74e676a24994bf..cee5cccfdd74ff943349c98f9083d1592f1f46b0 100644 (file)
@@ -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:<pre>".print_r($contractInstance, true)."</pre>");
+               ApplicationEntryPoint::app_exit("WITHDRAW:<pre>".print_r($contractInstance, true)."</pre>");
        }
 
        // Get latest added contract instance
index 7ba35384094554a53b00fe32e6a87e9f4b2cd74e..b6f4c45f5ba09ab297eaeb037510b7ae3e546ac4 100644 (file)
@@ -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 <span class=\"app_name\">%s</span> could not be launched because the helper class <span class=\"class_name\">%s</span> is not loaded.",
+       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_die(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; is not an object.",
+       ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; is not an object.",
                $application
        ));
 } elseif (!method_exists($app, FrameworkConfiguration::getSelfInstance()->getConfigEntry('entry_method'))) {
        // Method not found!
-       ApplicationEntryPoint::app_die(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.",
+       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')
        ));
index 14bb9504466ff9aa914294db40a3d8c68f96a7d4..28703323c3017a63b02c9c713bbefb76032d6d29 100644 (file)
--- a/index.php
+++ b/index.php
@@ -9,7 +9,7 @@
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @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