From: Roland Haeder <roland@mxchange.org>
Date: Wed, 15 Feb 2017 21:40:24 +0000 (+0100)
Subject: Continued rewriting:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c62a0884fc9334024a771f706ee89cd6321868c4;p=core.git

Continued rewriting:
- '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>
---

diff --git a/application/tests/data.php b/application/tests/data.php
index 7d50b587..e2132b75 100644
--- a/application/tests/data.php
+++ b/application/tests/data.php
@@ -1,8 +1,4 @@
 <?php
-// Import framework stuff
-use CoreFramework\Configuration\FrameworkConfiguration;
-use CoreFramework\Helper\Application\ApplicationHelper;
-
 /**
  * Application data
  *
@@ -29,12 +25,9 @@ use CoreFramework\Helper\Application\ApplicationHelper;
  * 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(
-	array($cfg->getConfigEntry('app_helper_class'), 'getSelfInstance'),
+	array('CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'),
 	array()
 );
 
diff --git a/application/tests/exceptions.php b/application/tests/exceptions.php
index da44cf5e..ea239eb5 100644
--- a/application/tests/exceptions.php
+++ b/application/tests/exceptions.php
@@ -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.
-		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);
 	}
 }
 
diff --git a/application/tests/loader.php b/application/tests/loader.php
index 089bb9f5..f551ef47 100644
--- a/application/tests/loader.php
+++ b/application/tests/loader.php
@@ -1,31 +1,3 @@
 <?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
 ?>
diff --git a/application/tests/starter.php b/application/tests/starter.php
index 26c1080e..b3f8d7d8 100644
--- a/application/tests/starter.php
+++ b/application/tests/starter.php
@@ -29,7 +29,7 @@ use CoreFramework\Configuration\FrameworkConfiguration;
 // maining the application
 $app = call_user_func_array(
 	array(
-		FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class'), 'getSelfInstance'
+		'CoreFramework\Helper\Application\ApplicationHelper', 'getSelfInstance'
 	), 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,
-		FrameworkConfiguration::getSelfInstance()->getConfigEntry('app_helper_class')
+		'CoreFramework\Helper\Application\ApplicationHelper'
 	));
 } elseif (!is_object($app)) {
 	// No object!
diff --git a/inc/config.php b/inc/config.php
index 605f6eab..4e9b902d 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -70,9 +70,6 @@ $cfg->setConfigEntry('code_template_extension', '.ctp');
 // 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');
 
diff --git a/inc/loader/class_ClassLoader.php b/inc/loader/class_ClassLoader.php
index 8886bd18..cef7d66e 100644
--- a/inc/loader/class_ClassLoader.php
+++ b/inc/loader/class_ClassLoader.php
@@ -338,7 +338,7 @@ class ClassLoader {
 		}
 
 		// 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
@@ -358,23 +358,23 @@ class ClassLoader {
 				$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?
-			//* 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
-				//* 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
-				//* 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
-			//* 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
 	}
@@ -429,12 +429,12 @@ class ClassLoader {
 		$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
-			//* 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]);
-			//* 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++;
@@ -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.
-			//* 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
-				//* 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
-			//* 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
-				//* 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
diff --git a/inc/selector.php b/inc/selector.php
index 19095dc1..7c8594f2 100644
--- a/inc/selector.php
+++ b/inc/selector.php
@@ -30,10 +30,9 @@ use CoreFramework\Object\BaseFrameworkSystem;
 
 // 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
-	'loader',		// The application's class loader
 	'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);
+
+// Scan for application's classes, exceptions and interfaces
+ClassLoader::scanApplicationClasses();