Continued rewriting:
authorRoland Haeder <roland@mxchange.org>
Wed, 15 Feb 2017 21:40:24 +0000 (22:40 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 28 Feb 2017 21:09:54 +0000 (22:09 +0100)
- 'loader.php' is now deprecated and also no longer loaded, instead selector.php
  (also deprecated but still around) will load application's classes
- class name ApplicationHelper is now hard-wired

Signed-off-by: Roland H├Ąder <roland@mxchange.org>
application/tests/data.php
application/tests/exceptions.php
application/tests/loader.php
application/tests/starter.php
inc/config.php
inc/loader/class_ClassLoader.php
inc/selector.php

index 7d50b58..e2132b7 100644 (file)
@@ -1,8 +1,4 @@
 <?php
 <?php
-// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
-use CoreFramework\Helper\Application\ApplicationHelper;
-
 /**
  * Application data
  *
 /**
  * Application data
  *
@@ -29,12 +25,9 @@ use CoreFramework\Helper\Application\ApplicationHelper;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-// Get config instance
-$cfg = FrameworkConfiguration::getSelfInstance();
-
 // Get an instance of the helper
 $app = call_user_func_array(
 // Get an instance of the helper
 $app = call_user_func_array(
-       array($cfg->getConfigEntry('app_helper_class'), 'getSelfInstance'),
+       array('CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'),
        array()
 );
 
        array()
 );
 
index da44cf5..ea239eb 100644 (file)
@@ -90,7 +90,7 @@ Backtrace:
                // Invalid exception instance detected! Do *only* throw exceptions that
                // extends our own exception 'FrameworkException' to get such nice
                // outputs like above.
                // Invalid exception instance detected! Do *only* throw exceptions that
                // extends our own exception 'FrameworkException' to get such nice
                // outputs like above.
-               print('exceptionInstance[]=' . gettype($exceptionInstance) . ' is invalid! Please inform the core developer team.');
+               print('exceptionInstance[]=' . gettype($exceptionInstance) . ' is invalid! Please inform the core developer team.' . PHP_EOL);
        }
 }
 
        }
 }
 
index 089bb9f..f551ef4 100644 (file)
@@ -1,31 +1,3 @@
 <?php
 <?php
-// Import framework stuff
-use CoreFramework\Loader\ClassLoader;
-
-/**
- * The application's class loader
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
- * @license            GNU GPL 3.0 or any newer version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-// Scan for application's classes, exceptions and interfaces
-ClassLoader::scanApplicationClasses();
-
-// [EOF]
+// @DEPRECATED
 ?>
 ?>
index 26c1080..b3f8d7d 100644 (file)
@@ -29,7 +29,7 @@ use CoreFramework\Configuration\FrameworkConfiguration;
 // maining the application
 $app = call_user_func_array(
        array(
 // maining the application
 $app = call_user_func_array(
        array(
-               FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class'), 'getSelfInstance'
+               'CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
        ), array()
 );
 
        ), array()
 );
 
@@ -38,7 +38,7 @@ if ((empty($app)) || (is_null($app))) {
        // 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.",
                $application,
        // 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.",
                $application,
-               FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class')
+               'CoreFramework\Helper\Application\ApplicationHelper'
        ));
 } elseif (!is_object($app)) {
        // No object!
        ));
 } elseif (!is_object($app)) {
        // No object!
index 605f6ea..4e9b902 100644 (file)
@@ -70,9 +70,6 @@ $cfg->setConfigEntry('code_template_extension', '.ctp');
 // CFG: SELECTOR-PATH
 $cfg->setConfigEntry('selector_path', 'selector');
 
 // CFG: SELECTOR-PATH
 $cfg->setConfigEntry('selector_path', 'selector');
 
-// CFG: APPLICATION-HELPER-CLASS
-$cfg->setConfigEntry('app_helper_class', 'ApplicationHelper');
-
 // CFG: LAUNCH-METHOD
 $cfg->setConfigEntry('entry_method', 'entryPoint');
 
 // CFG: LAUNCH-METHOD
 $cfg->setConfigEntry('entry_method', 'entryPoint');
 
index 8886bd1..cef7d66 100644 (file)
@@ -338,7 +338,7 @@ class ClassLoader {
                }
 
                // Get a new iterator
                }
 
                // Get a new iterator
-               //* NOISY-DEBUG: */ printf('[%s:%d] basePath=%s' . PHP_EOL, __METHOD__, __LINE__, $basePath);
+               /* NOISY-DEBUG: */ printf('[%s:%d] basePath=%s' . PHP_EOL, __METHOD__, __LINE__, $basePath);
                $iteratorInstance = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basePath), RecursiveIteratorIterator::CHILD_FIRST);
 
                // Load all entries
                $iteratorInstance = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basePath), RecursiveIteratorIterator::CHILD_FIRST);
 
                // Load all entries
@@ -358,23 +358,23 @@ class ClassLoader {
                                $iteratorInstance->next();
 
                                // Skip non-file entries
                                $iteratorInstance->next();
 
                                // Skip non-file entries
-                               //* NOISY-DEBUG: */ printf('[%s:%d] SKIP: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+                               /* NOISY-DEBUG: */ printf('[%s:%d] SKIP: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                                continue;
                        } // END - if
 
                        // Is this file wanted?
                                continue;
                        } // END - if
 
                        // Is this file wanted?
-                       //* NOISY-DEBUG: */ printf('[%s:%d] FOUND: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+                       /* NOISY-DEBUG: */ printf('[%s:%d] FOUND: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                        if ((substr($fileName, 0, strlen($this->prefix)) == $this->prefix) && (substr($fileName, -strlen($this->suffix), strlen($this->suffix)) == $this->suffix)) {
                                // Add it to the list
                        if ((substr($fileName, 0, strlen($this->prefix)) == $this->prefix) && (substr($fileName, -strlen($this->suffix), strlen($this->suffix)) == $this->suffix)) {
                                // Add it to the list
-                               //* NOISY-DEBUG: */ printf('[%s:%d] ADD: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
+                               /* NOISY-DEBUG: */ printf('[%s:%d] ADD: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
                                $this->classes[$fileName] = $fqfn;
                        } else {
                                // Not added
                                $this->classes[$fileName] = $fqfn;
                        } else {
                                // Not added
-                               //* NOISY-DEBUG: */ printf('[%s:%d] NOT ADDED: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
+                               /* NOISY-DEBUG: */ printf('[%s:%d] NOT ADDED: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
                        }
 
                        // Advance to next entry
                        }
 
                        // Advance to next entry
-                       //* NOISY-DEBUG: */ printf('[%s:%d] NEXT: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+                       /* NOISY-DEBUG: */ printf('[%s:%d] NEXT: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                        $iteratorInstance->next();
                } // END - while
        }
                        $iteratorInstance->next();
                } // END - while
        }
@@ -429,12 +429,12 @@ class ClassLoader {
                $fileName = $this->prefix . $shortClassName . $this->suffix;
 
                // Now look it up in our index
                $fileName = $this->prefix . $shortClassName . $this->suffix;
 
                // Now look it up in our index
-               //* NOISY-DEBUG: */ printf('[%s:%d] ISSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+               /* NOISY-DEBUG: */ printf('[%s:%d] ISSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                if ((isset($this->classes[$fileName])) && (!in_array($this->classes[$fileName], $this->loadedClasses))) {
                        // File is found and not loaded so load it only once
                if ((isset($this->classes[$fileName])) && (!in_array($this->classes[$fileName], $this->loadedClasses))) {
                        // File is found and not loaded so load it only once
-                       //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+                       /* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                        require($this->classes[$fileName]);
                        require($this->classes[$fileName]);
-                       //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - END' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+                       /* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - END' . PHP_EOL, __METHOD__, __LINE__, $fileName);
 
                        // Count this loaded class/interface/exception
                        $this->total++;
 
                        // Count this loaded class/interface/exception
                        $this->total++;
@@ -443,18 +443,18 @@ class ClassLoader {
                        array_push($this->loadedClasses, $this->classes[$fileName]);
 
                        // Remove it from classes list so it won't be found twice.
                        array_push($this->loadedClasses, $this->classes[$fileName]);
 
                        // Remove it from classes list so it won't be found twice.
-                       //* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+                       /* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                        unset($this->classes[$fileName]);
 
                        // Developer mode excludes caching (better debugging)
                        if (!defined('DEVELOPER')) {
                                // Reset cache
                        unset($this->classes[$fileName]);
 
                        // Developer mode excludes caching (better debugging)
                        if (!defined('DEVELOPER')) {
                                // Reset cache
-                               //* NOISY-DEBUG: */ printf('[%s:%d] classesCached=FALSE' . PHP_EOL, __METHOD__, __LINE__);
+                               /* NOISY-DEBUG: */ printf('[%s:%d] classesCached=FALSE' . PHP_EOL, __METHOD__, __LINE__);
                                $this->classesCached = FALSE;
                        } // END - if
                } else {
                        // Not found
                                $this->classesCached = FALSE;
                        } // END - if
                } else {
                        // Not found
-                       //* NOISY-DEBUG: */ printf('[%s:%d] 404: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+                       /* NOISY-DEBUG: */ printf('[%s:%d] 404: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                }
        }
 
                }
        }
 
@@ -472,7 +472,7 @@ class ClassLoader {
                                require($fqfn);
 
                                // Remove it from the list
                                require($fqfn);
 
                                // Remove it from the list
-                               //* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+                               /* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                                unset($this->classes[$fileName]);
                        } // END - if
                } // END - foreach
                                unset($this->classes[$fileName]);
                        } // END - if
                } // END - foreach
index 19095dc..7c8594f 100644 (file)
@@ -30,10 +30,9 @@ use CoreFramework\Object\BaseFrameworkSystem;
 
 // Try to load these includes in the given order
 $configAppIncludes = array(
 
 // Try to load these includes in the given order
 $configAppIncludes = array(
-       'class_' . FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class'), // The ApplicationHelper class
+       'class_ApplicationHelper', // The ApplicationHelper class
        'debug',                // Some debugging stuff
        'exceptions',   // The application's own exception handler
        'debug',                // Some debugging stuff
        'exceptions',   // The application's own exception handler
-       'loader',               // The application's class loader
        'config',               // The application's own configuration
        'config-local', // Local configuration file (optional)
        'data',                 // Application data
        'config',               // The application's own configuration
        'config-local', // Local configuration file (optional)
        'data',                 // Application data
@@ -82,3 +81,6 @@ unset($appInc);
 unset($configAppIncludes);
 unset($appFqFn);
 unset($basePathFile);
 unset($configAppIncludes);
 unset($appFqFn);
 unset($basePathFile);
+
+// Scan for application's classes, exceptions and interfaces
+ClassLoader::scanApplicationClasses();