Continued a bit:
authorRoland Häder <roland@mxchange.org>
Sun, 16 Jul 2017 10:56:32 +0000 (12:56 +0200)
committerRoland Häder <roland@mxchange.org>
Sun, 16 Jul 2017 10:58:52 +0000 (12:58 +0200)
- renamed method app_exit() to exitApplication(), still it needs rewritings
- rewrote a bit searching for framework files, also check __DIR__ from
  index.php to find it

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/bootstrap/class_FrameworkBootstrap.php
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/criteria/dataset/class_DataSetCriteria.php
framework/main/classes/file_directories/io_stream/class_FileIoStream.php
framework/main/classes/template/class_BaseTemplateEngine.php
index.php

index 000a2a9dde99952af94b2b053a5c7c4511d02883..0864970fd68d75490852bce15549e29e9c15242d 100644 (file)
@@ -282,10 +282,10 @@ final class FrameworkBootstrap {
                        // Determine if this file is wanted/readable/deprecated
                        if (($status == 'required') && (!self::isReadableFile($fqfn))) {
                                // Nope, required file cannot be found/read from
                        // Determine if this file is wanted/readable/deprecated
                        if (($status == 'required') && (!self::isReadableFile($fqfn))) {
                                // Nope, required file cannot be found/read from
-                               ApplicationEntryPoint::app_exit(sprintf('Application "%s" does not have required file "%s.php". Please add it.', $application, $fileName));
+                               ApplicationEntryPoint::exitApplication(sprintf('Application "%s" does not have required file "%s.php". Please add it.', $application, $fileName));
                        } elseif ((file_exists($fqfn)) && (!is_readable($fqfn))) {
                                // Found, not readable file
                        } elseif ((file_exists($fqfn)) && (!is_readable($fqfn))) {
                                // Found, not readable file
-                               ApplicationEntryPoint::app_exit(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileName, $application));
+                               ApplicationEntryPoint::exitApplication(sprintf('File "%s.php" from application "%s" cannot be read. Please fix CHMOD.', $fileName, $application));
                        } elseif (($status != 'required') && (!self::isReadableFile($fqfn))) {
                                // Not found but optional/deprecated file, skip it
                                continue;
                        } elseif (($status != 'required') && (!self::isReadableFile($fqfn))) {
                                // Not found but optional/deprecated file, skip it
                                continue;
@@ -328,19 +328,19 @@ final class FrameworkBootstrap {
                // Some sanity checks
                if ((empty($applicationInstance)) || (is_null($applicationInstance))) {
                        // Something went wrong!
                // Some sanity checks
                if ((empty($applicationInstance)) || (is_null($applicationInstance))) {
                        // 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.",
+                       ApplicationEntryPoint::exitApplication(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,
                                'CoreFramework\Helper\Application\ApplicationHelper'
                        ));
                } elseif (!is_object($applicationInstance)) {
                        // No object!
                                $application,
                                'CoreFramework\Helper\Application\ApplicationHelper'
                        ));
                } elseif (!is_object($applicationInstance)) {
                        // No 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 (%s).",
+                       ApplicationEntryPoint::exitApplication(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; is not an object (%s).",
                                $application,
                                gettype($applicationInstance)
                        ));
                } elseif (!($applicationInstance instanceof ManageableApplication)) {
                        // Missing interface
                                $application,
                                gettype($applicationInstance)
                        ));
                } elseif (!($applicationInstance instanceof ManageableApplication)) {
                        // Missing interface
-                       ApplicationEntryPoint::app_exit(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; is lacking required interface ManageableApplication.",
+                       ApplicationEntryPoint::exitApplication(sprintf("[Main:] The application <span class=\"app_name\">%s</span> could not be launched because &#39;app&#39; is lacking required interface ManageableApplication.",
                                $application
                        ));
                }
                                $application
                        ));
                }
@@ -451,7 +451,7 @@ final class FrameworkBootstrap {
                         * supported and only existed as an idea to select the proper
                         * application (by user).
                         */
                         * supported and only existed as an idea to select the proper
                         * application (by user).
                         */
-                       ApplicationEntryPoint::app_exit('No application specified. Please provide a parameter "app" and retry.');
+                       ApplicationEntryPoint::exitApplication('No application specified. Please provide a parameter "app" and retry.');
                } // END - if
 
                // Get it for local usage
                } // END - if
 
                // Get it for local usage
@@ -475,7 +475,7 @@ final class FrameworkBootstrap {
                // Is the path there? This secures a bit the parameter (from untrusted source).
                if ((!is_dir($applicationPath)) || (!is_readable($applicationPath))) {
                        // Not found or not readable
                // Is the path there? This secures a bit the parameter (from untrusted source).
                if ((!is_dir($applicationPath)) || (!is_readable($applicationPath))) {
                        // Not found or not readable
-                       ApplicationEntryPoint::app_exit(sprintf('Application "%s" not found.', $application));
+                       ApplicationEntryPoint::exitApplication(sprintf('Application "%s" not found.', $application));
                } // END - if
 
                // Set the detected application's name and full path for later usage
                } // END - if
 
                // Set the detected application's name and full path for later usage
index 322bd28263da9984da6176ce53c2c31516f32a58..56fd139686edb539d67e7bc28b8b289a61fc8922 100644 (file)
@@ -1749,7 +1749,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface {
                );
 
                // Output it
                );
 
                // Output it
-               ApplicationEntryPoint::app_exit(sprintf('<div class="debug_header">
+               ApplicationEntryPoint::exitApplication(sprintf('<div class="debug_header">
        %s debug output:
 </div>
 <div class="debug_content">
        %s debug output:
 </div>
 <div class="debug_content">
index 22419d1ea77c5866322632c4426a70e1e3b064e7..8e00cc2c21e0a6f94e7fd88365e3b3994268ce95 100644 (file)
@@ -167,7 +167,7 @@ class DataSetCriteria extends BaseCriteria implements StoreableCriteria {
                        // Is it empty, too?
                        if (empty($uniqueKey)) {
                                // Bad news, nothing is "unique" by design for this table
                        // Is it empty, too?
                        if (empty($uniqueKey)) {
                                // Bad news, nothing is "unique" by design for this table
-                               ApplicationEntryPoint::app_exit('Table ' . $this->getTableName() . ' has both no primary and unique key, but ' . __METHOD__ . ' was called. Please fix your table.');
+                               ApplicationEntryPoint::exitApplication('Table ' . $this->getTableName() . ' has both no primary and unique key, but ' . __METHOD__ . ' was called. Please fix your table.');
                        } else {
                                // Return unique key
                                return $uniqueKey;
                        } else {
                                // Return unique key
                                return $uniqueKey;
index 8bfe15209b95cd7c338bbf9982af43300050faf5..51406cbea3bafa2399c0d2131dae505caba3aa9e 100644 (file)
@@ -96,7 +96,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
                                $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_output_class', array($fileName, 'wb'));
                        } catch (FileNotFoundException $e) {
                                // Bail out
                                $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_output_class', array($fileName, 'wb'));
                        } catch (FileNotFoundException $e) {
                                // Bail out
-                               ApplicationEntryPoint::app_exit('The application has made a fatal error. Exception: ' . $e->__toString() . ' with message: ' . $e->getMessage());
+                               ApplicationEntryPoint::exitApplication('The application has made a fatal error. Exception: ' . $e->__toString() . ' with message: ' . $e->getMessage());
                        }
                } // END - for
 
                        }
                } // END - for
 
index cdd906716e18d1d0f5915ec9edbff8d34c9787fe..a233e776e1e2386812a0efc8bf2d2f30b5e91968 100644 (file)
@@ -987,7 +987,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem {
                                $this->assignVariable($var, $varMatches[3][$key]);
                        } elseif (!empty($varMatches[2][$key])) {
                                // @TODO Non-string found so we need some deeper analysis...
                                $this->assignVariable($var, $varMatches[3][$key]);
                        } elseif (!empty($varMatches[2][$key])) {
                                // @TODO Non-string found so we need some deeper analysis...
-                               ApplicationEntryPoint::app_exit('Deeper analysis not yet implemented!');
+                               ApplicationEntryPoint::exitApplication('Deeper analysis not yet implemented!');
                        }
                } // END - foreach
        }
                        }
                } // END - foreach
        }
index 753e54afef0c09cffd916413bb5bc1b00a937ca9..f2dae4d4532e325a56758c1a7dc28e2e56871cb7 100644 (file)
--- a/index.php
+++ b/index.php
@@ -58,7 +58,7 @@ final class ApplicationEntryPoint {
         * @return      void
         * @todo        This method is old code and needs heavy rewrite and should be moved to ApplicationHelper
         */
         * @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 exitApplication ($message = '', $code = false, $extraData = '', $silentMode = false) {
                // Is this method already called?
                if (isset($GLOBALS['app_die_called'])) {
                        // Then output the text directly
                // Is this method already called?
                if (isset($GLOBALS['app_die_called'])) {
                        // Then output the text directly
@@ -193,7 +193,7 @@ final class ApplicationEntryPoint {
                // Is it not set?
                if (empty(self::$frameworkPath)) {
                        // Auto-detect core path (first application-common)
                // Is it not set?
                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) {
+                       foreach (array('core', __DIR__, '/usr/local/share/php/core', '/usr/share/php/core') as $possiblePath) {
                                // Create full path for testing
                                $realPath = realpath($possiblePath);
 
                                // Create full path for testing
                                $realPath = realpath($possiblePath);
 
@@ -206,22 +206,19 @@ final class ApplicationEntryPoint {
                                        continue;
                                } // END - if
 
                                        continue;
                                } // END - if
 
+                               // Append framework path
+                               $frameworkPath = sprintf('%s%sframework%s', $realPath, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
+
                                // First create full-qualified file name (FQFN) to framework/config-global.php
                                // 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
-                               );
+                               $configFile = $frameworkPath . 'config-global.php';
 
                                // Debug message
 
                                // Debug message
-                               //* NOISY-DEBUG: */ printf('[%s:%d]: fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fqfn);
+                               //* NOISY-DEBUG: */ printf('[%s:%d]: configFile=%s' . PHP_EOL, __METHOD__, __LINE__, $configFile);
 
                                // Is it readable?
 
                                // Is it readable?
-                               if (is_readable($fqfn)) {
+                               if (is_readable($configFile)) {
                                        // Found one
                                        // Found one
-                                       self::$frameworkPath = $realPath . '/framework/';
+                                       self::$frameworkPath = $frameworkPath;
 
                                        // Abort here
                                        break;
 
                                        // Abort here
                                        break;