]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 10:11:30 +0000 (11:11 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 10:11:30 +0000 (11:11 +0100)
- rewrote deprecated DEVELOPER constant to developer_mode_enabled configuration
  entry
- added missing "import" line for exception

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/config-global.php
framework/config/class_FrameworkConfiguration.php
framework/loader/class_ClassLoader.php
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/filter/payment/class_PaymentDiscoveryFilter.php
framework/main/classes/helper/html/links/class_HtmlLinkHelper.php
index.php
tests/framework/config/FrameworkConfigurationTest.php

index 2476e47e65950fb06fc1331123bb83002356440c..4de24029e30ca596324a0b54994a34e06221f6ee 100644 (file)
@@ -461,7 +461,7 @@ $cfg->setConfigEntry('extension_uuid_loaded', false);
 $cfg->setConfigEntry('registry_iterator_class', 'Org\Mxchange\CoreFramework\Iterator\Registry\RegistryIterator');
 
 // CFG: QUIET-DNS-RESOLVER
-$cfg->setConfigEntry('quiet_dns_resolver', FALSE);
+$cfg->setConfigEntry('quiet_dns_resolver', false);
 
 // CFG: THOUSANDS-SEPARATOR
 $cfg->setConfigEntry('thousands_separator', '.');
@@ -477,3 +477,6 @@ $cfg->setConfigEntry('crypto_openssl_stream_class', 'Org\Mxchange\CoreFramework\
 
 // CFG: CRYPTO-NULL-STREAM-CLASS
 $cfg->setConfigEntry('crypto_null_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\Null\NullCryptoStream');
+
+// CFG: DEVELOPER-MODE-ENABLED
+$cfg->setConfigEntry('developer_mode_enabled', true);
index 6e969ccbdc9c76ede5d8353855425c3412edb8b6..0d5560a550ac10708d1f97a9e2406938f91074d9 100644 (file)
@@ -4,6 +4,7 @@
 namespace Org\Mxchange\CoreFramework\Configuration;
 
 // Import framework stuff
+use Org\Mxchange\CoreFramework\Configuration\NoConfigEntryException;
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
@@ -135,7 +136,7 @@ class FrameworkConfiguration implements Registerable {
                if (!$this->isConfigurationEntrySet($configKey)) {
                        // Entry was not found!
                        throw new NoConfigEntryException(array(__CLASS__, $configKey), self::EXCEPTION_CONFIG_KEY_WAS_NOT_FOUND);
-               } // END - if
+               }
 
                // Return the requested value
                return self::$config[$configKey];
@@ -218,7 +219,7 @@ class FrameworkConfiguration implements Registerable {
                if (!$this->isConfigurationEntrySet($configKey)) {
                        // Entry was not found!
                        throw new NoConfigEntryException(array(__CLASS__, $configKey), self::EXCEPTION_CONFIG_KEY_WAS_NOT_FOUND);
-               } // END - if
+               }
 
                // Unset it
                unset(self::$config[$configKey]);
index 194e89f17291b44a12b5f16f35a45f571883a61b..72d25add1524733dbdfdcf9f5903d4427ac1235e 100644 (file)
@@ -154,9 +154,9 @@ class ClassLoader {
         */
        public function __destruct () {
                // Skip here if dev-mode
-               if (defined('DEVELOPER')) {
+               if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) {
                        return;
-               } // END - if
+               }
 
                // Skip here if already cached
                if ($this->listCached === false) {
@@ -168,7 +168,7 @@ class ClassLoader {
 
                        // And write whole list
                        $fileObject->fwrite($cacheContent);
-               } // END - if
+               }
 
                // Skip here if already cached
                if ($this->classesCached === false) {
@@ -181,14 +181,14 @@ class ClassLoader {
                                // Load the file
                                // @TODO Add some uglifying code (compress) here
                                $cacheContent .= $fileObject->fread($fileInstance->getSize());
-                       } // END - foreach
+                       }
 
                        // Open file
                        $fileObject = $this->classCacheFile->openFile('w');
 
                        // And write it away
                        $fileObject->fwrite($cacheContent);
-               } // END - if
+               }
        }
 
        /**
@@ -214,10 +214,8 @@ class ClassLoader {
         * @return      void
         */
        public static function scanFrameworkClasses () {
-               // Trace message
-               //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
-
                // Get loader instance
+               //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
                $loaderInstance = self::getSelfInstance();
 
                // Get config instance
@@ -225,10 +223,8 @@ class ClassLoader {
 
                // Load all classes
                foreach (self::$frameworkPaths as $shortPath) {
-                       // Debug message
-                       //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath);
-
                        // Generate full path from it
+                       //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath);
                        $realPathName = realpath(sprintf(
                                '%smain%s%s%s',
                                $configInstance->getConfigEntry('framework_base_path'),
@@ -237,10 +233,8 @@ class ClassLoader {
                                DIRECTORY_SEPARATOR
                        ));
 
-                       // Debug message
-                       //* NOISY-DEBUG: */ printf('[%s:%d]: realPathName=%s' . PHP_EOL, __METHOD__, __LINE__, $realPathName);
-
                        // Is it not false and accessible?
+                       //* NOISY-DEBUG: */ printf('[%s:%d]: realPathName=%s' . PHP_EOL, __METHOD__, __LINE__, $realPathName);
                        if (is_bool($realPathName)) {
                                // Skip this
                                continue;
@@ -251,7 +245,7 @@ class ClassLoader {
 
                        // Try to load the framework classes
                        $loaderInstance->scanClassPath($realPathName);
-               } // END - foreach
+               }
 
                // Trace message
                //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
@@ -263,10 +257,8 @@ class ClassLoader {
         * @return      void
         */
        public static function scanApplicationClasses () {
-               // Trace message
-               //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
-
                // Get loader instance
+               //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
                $loaderInstance = self::getSelfInstance();
 
                // Get config instance
@@ -274,10 +266,8 @@ class ClassLoader {
 
                // Load all classes for the application
                foreach (self::$frameworkPaths as $shortPath) {
-                       // Debug message
-                       //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath);
-
                        // Create path name
+                       //* NOISY-DEBUG: */ printf('[%s:%d]: shortPath=%s' . PHP_EOL, __METHOD__, __LINE__, $shortPath);
                        $pathName = realpath(sprintf(
                                '%s%s%s%s%s',
                                $configInstance->getConfigEntry('application_base_path'),
@@ -287,15 +277,13 @@ class ClassLoader {
                                $shortPath
                        ));
 
-                       // Debug message
-                       //* NOISY-DEBUG: */ printf('[%s:%d]: pathName[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($pathName), $pathName);
-
                        // Is the path readable?
+                       //* NOISY-DEBUG: */ printf('[%s:%d]: pathName[%s]=%s' . PHP_EOL, __METHOD__, __LINE__, gettype($pathName), $pathName);
                        if (is_dir($pathName)) {
                                // Try to load the application classes
                                $loaderInstance->scanClassPath($pathName);
-                       } // END - if
-               } // END - foreach
+                       }
+               }
 
                // Trace message
                //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
@@ -326,21 +314,17 @@ class ClassLoader {
                                $shortPath
                        );
 
-                       // Debug message
-                       //* NOISY-DEBUG: */ printf('[%s:%d]: pathName[%s]=%s - BEFORE!' . PHP_EOL, __METHOD__, __LINE__, gettype($pathName), $pathName);
-
                        // Try to find it
+                       //* NOISY-DEBUG: */ printf('[%s:%d]: pathName[%s]=%s - BEFORE!' . PHP_EOL, __METHOD__, __LINE__, gettype($pathName), $pathName);
                        $realPathName = realpath($pathName);
 
-                       // Debug message
-                       //* NOISY-DEBUG: */ printf('[%s:%d]: realPathName[%s]=%s - AFTER!' . PHP_EOL, __METHOD__, __LINE__, gettype($realPathName), $realPathName);
-
                        // Is the path readable?
+                       //* NOISY-DEBUG: */ printf('[%s:%d]: realPathName[%s]=%s - AFTER!' . PHP_EOL, __METHOD__, __LINE__, gettype($realPathName), $realPathName);
                        if ((is_dir($realPathName)) && (is_readable($realPathName))) {
                                // Try to load the application classes
                                ClassLoader::getSelfInstance()->scanClassPath($realPathName);
-                       } // END - if
-               } // END - foreach
+                       }
+               }
 
                // Trace message
                //* NOISY-DEBUG: */ printf('[%s:%d]: EXIT!' . PHP_EOL, __METHOD__, __LINE__);
@@ -364,10 +348,8 @@ class ClassLoader {
         * @return      void
         */
        public static function registerTestsPath (string $relativePath) {
-               // Trace message
-               //* NOISY-DEBUG: */ printf('[%s:%d]: relativePath=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $relativePath);
-
                // "Register" it
+               //* NOISY-DEBUG: */ printf('[%s:%d]: relativePath=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $relativePath);
                self::$testPaths[$relativePath] = $relativePath;
 
                // Trace message
@@ -401,7 +383,7 @@ class ClassLoader {
                if (is_null(self::$selfInstance)) {
                        // Get a new one
                        self::$selfInstance = ClassLoader::createClassLoader(FrameworkBootstrap::getConfigurationInstance());
-               } // END - if
+               }
 
                // Return the instance
                return self::$selfInstance;
@@ -419,7 +401,7 @@ class ClassLoader {
                if ($this->listCached === true) {
                        // Abort here
                        return;
-               } // END - if
+               }
 
                // Keep it in class for later usage
                $this->ignoreList = $ignoreList;
@@ -466,7 +448,7 @@ class ClassLoader {
                                // Skip non-file entries
                                //* 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);
@@ -482,7 +464,7 @@ class ClassLoader {
                        // Advance to next entry
                        //* NOISY-DEBUG: */ printf('[%s:%d] NEXT: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
                        $iteratorInstance->next();
-               } // END - while
+               }
        }
 
        /**
@@ -504,7 +486,7 @@ class ClassLoader {
                $includeList = '';
                foreach ($this->loadedClasses as $classFile) {
                        $includeList .= basename($classFile) . '<br />' . PHP_EOL;
-               } // END - foreach
+               }
 
                // And return it
                return $includeList;
@@ -521,10 +503,11 @@ class ClassLoader {
                $this->configInstance = $configInstance;
 
                // Construct the FQFN for the cache
-               if (!defined('DEVELOPER')) {
+               if (!FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) {
+                       // Init cache instances
                        $this->listCacheFile  = new SplFileInfo($this->configInstance->getConfigEntry('local_database_path') . 'list-' . $this->configInstance->getConfigEntry('detected_app_name') . '.cache');
                        $this->classCacheFile = new SplFileInfo($this->configInstance->getConfigEntry('local_database_path') . 'class-' . $this->configInstance->getConfigEntry('detected_app_name') . '.cache');
-               } // END - if
+               }
 
                // Set suffix and prefix from configuration
                $this->suffix = $configInstance->getConfigEntry('class_suffix');
@@ -534,9 +517,9 @@ class ClassLoader {
                self::$selfInstance = $this;
 
                // Skip here if no dev-mode
-               if (defined('DEVELOPER')) {
+               if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) {
                        return;
-               } // END - if
+               }
 
                // Is the cache there?
                if (FrameworkBootstrap::isReadableFile($this->listCacheFile)) {
@@ -545,7 +528,7 @@ class ClassLoader {
 
                        // List has been restored from cache!
                        $this->listCached = true;
-               } // END - if
+               }
 
                // Does the class cache exist?
                if (FrameworkBootstrap::isReadableFile($this->classCacheFile)) {
@@ -554,7 +537,7 @@ class ClassLoader {
 
                        // Mark the class cache as loaded
                        $this->classesCached = true;
-               } // END - if
+               }
        }
 
        /**
@@ -575,7 +558,7 @@ class ClassLoader {
                if ((self::$strictNamingConvention === true) && (count($classNameParts) < 5)) {
                        // Namespace scheme is: Project\Package[\SubPackage...]
                        throw new InvalidArgumentException(sprintf('Class name "%s" is not conform to naming-convention: Tld\Domain\Project\Package[\SubPackage...]\SomeFooBar', $className));
-               } // END - if
+               }
 
                // Get last element
                $shortClassName = array_pop($classNameParts);
@@ -602,11 +585,11 @@ class ClassLoader {
                        unset($this->foundClasses[$fileName]);
 
                        // Developer mode excludes caching (better debugging)
-                       if (!defined('DEVELOPER')) {
+                       if (!FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) {
                                // Reset cache
                                //* 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);
index 274fb7d62f097c5ed7d8e1597d22444c722645ce..6280c51517baf79ba8460022e22ec6aa36cb887d 100644 (file)
@@ -829,7 +829,7 @@ Loaded includes:
                if ($this->isFieldSet($fieldName)) {
                        // Get it
                        $fieldValue = $fieldArray[$fieldName2];
-               } elseif (defined('DEVELOPER')) {
+               } elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) {
                        // Missing field entry, may require debugging
                        self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray<pre>=' . print_r($fieldArray, true) . '</pre>,fieldName=' . $fieldName . ' not found!');
                } else {
@@ -881,7 +881,7 @@ Loaded includes:
         */
        public function deprecationWarning ($message) {
                // Is developer mode active?
-               if (defined('DEVELOPER')) {
+               if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) {
                        // Debug instance is there?
                        if (!is_null($this->getDebugInstance())) {
                                // Output stub message
index d735b561a582583e5e3e916379d2bf617b85df81..08737bdf1d6a1bbeafaef853fce053e2cd294de1 100644 (file)
@@ -4,6 +4,7 @@ namespace Org\Mxchange\CoreFramework\Filter\Discovery\Payment;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Action\PerformableAction;
+use Org\Mxchange\CoreFramework\Configuration\NoConfigEntryException;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Filter\BaseFilter;
 use Org\Mxchange\CoreFramework\Filter\Chain\FilterChainException;
index b97e0810389320ea544902c967edd66db60ba4d1..2dd3319c4d18a821b01c5879148c6051e998eb0c 100644 (file)
@@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Helper;
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Configuration\FrameworkConfiguration;
+use Org\Mxchange\CoreFramework\Configuration\NoConfigEntryException;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
index 79e7ce8ccd5b73f32998b5060dbafbe8f9e8bce5..818fb7386a86c0b9dec9db7fc259b495d9955c13 100644 (file)
--- a/index.php
+++ b/index.php
@@ -274,9 +274,6 @@ final class ApplicationEntryPoint {
        }
 }
 
-// Developer mode active? Comment out if no dev!
-define('DEVELOPER', true);
-
 // Log all exceptions (only debug! This option can create large error logs)
 //define('LOG_EXCEPTIONS', true);
 
index d1a5033be630292a0ab3c235e49ac5a811911755..6506e2d64d9df3ab8ec181bd74ea7ab317bf3c62 100644 (file)
@@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Configuration;
 // Inport framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Configuration\FrameworkConfiguration;
+use Org\Mxchange\CoreFramework\Configuration\NoConfigEntryException;
 use Org\Mxchange\CoreFramework\Loader\ClassLoader;
 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
 use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;