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 d9cc8d9..1a93fc0 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 d28600b..bcb574f 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 7ba3538..b6f4c45 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 efbb161..7b380c2 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 d9cc8d9..8e4e14f 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 d28600b..bcb574f 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 de959b6..cee5ccc 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 7ba3538..b6f4c45 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 14bb950..2870332 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