Continued:
[core.git] / index.php
index 0a3ef741158afd0be661a3d36b0c1b63d8e4c89b..3ba9290f823a382fa3c6d47cebf42227d0f9913e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,4 +1,14 @@
 <?php
+// Own namespace (watch out: core)
+namespace CoreFramework\EntryPoint;
+
+// Import framework stuff
+use CoreFramework\Configuration\FrameworkConfiguration;
+use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Helper\Application\ApplicationHelper;
+use CoreFramework\Loader\ClassLoader;
+use CoreFramework\Generic\FrameworkException;
+
 /**
  * The main class with the entry point to the whole application. This class
  * "emulates" Java's entry point call. Additionally it covers local
@@ -117,7 +127,7 @@ final class ApplicationEntryPoint {
                        $applicationInstance = NULL;
 
                        // Is the class there?
-                       if (class_exists('ApplicationHelper')) {
+                       if (class_exists('CoreFramework\Helper\Application\ApplicationHelper')) {
                                // Get application instance
                                $applicationInstance = ApplicationHelper::getSelfInstance();
 
@@ -167,15 +177,50 @@ final class ApplicationEntryPoint {
 
        /**
         * Determines the correct absolute path for all includes only once per run.
-        * Other calls of this method are being "cached".
+        * Other calls of this method are being "cached". This is done by checking
+        * a small list of common paths where the framework can reside and check if
+        * framework/config.php can be found.
         *
         * @return      $corePath       Base path (core) for all includes
         */
        protected static final function detectCorePath () {
                // Is it not set?
                if (empty(self::$corePath)) {
-                       // Auto-detect our core path
-                       self::$corePath = str_replace("\\", '/', dirname(__FILE__));
+                       // Auto-detect core path (first application-common)
+                       foreach (array('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.php
+                               $fqfn = sprintf(
+                                       '%s%sframework%sconfig.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::$corePath = $realPath;
+
+                                       // Abort here
+                                       break;
+                               } // END - if
+                       } // END - foreach
                } // END - if
 
                // Return it
@@ -183,24 +228,32 @@ final class ApplicationEntryPoint {
        }
 
        /**
-        * The application's main entry point. This class isolates some local
+        * 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 config file, this no longer provides $cfg
+               require(self::detectCorePath() . '/framework/config.php');
+
+               // Get a new configuration instance
+               $cfg = FrameworkConfiguration::getSelfInstance();
+
+               // Load bootstrap class
+               require($cfg->getConfigEntry('base_path') . 'framework/bootstrap/class_BootstrapFramework.php');
+
+               // ----- Below is deprecated -----
 
                // Load all include files
-               require($cfg->getConfigEntry('base_path') . 'inc/includes.php');
+               require($cfg->getConfigEntry('base_path') . 'framework/includes.php');
 
                // Include the application selector
-               require($cfg->getConfigEntry('base_path') . 'inc/selector.php');
-       } // END - main()
-} // END - class
+               require($cfg->getConfigEntry('base_path') . 'framework/selector.php');
+       }
+}
 
 // Developer mode active? Comment out if no dev!
 define('DEVELOPER', TRUE);
@@ -210,8 +263,5 @@ define('DEVELOPER', TRUE);
 
 //xdebug_start_trace();
 
-// Do not remove the following line:
+// Call above main() method
 ApplicationEntryPoint::main();
-
-// [EOF]
-?>