]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 7 Nov 2020 18:02:21 +0000 (19:02 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 7 Nov 2020 18:02:21 +0000 (19:02 +0100)
- reduced monolithic BaseFrameworkSystem by moving $rngInstance, $imageInstance
  and $menuInstance with getter/setter to proper classes

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/config-global.php
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/crypto/class_CryptoHelper.php
framework/main/classes/helper/captcha/class_BaseCaptcha.php
framework/main/classes/response/image/class_ImageResponse.php
framework/main/classes/template/image/class_ImageTemplateEngine.php
framework/main/classes/template/menu/class_MenuTemplateEngine.php

index 24eecc9edb963cf2a8df124c8b69f273480f0f25..1a3819e9aceae9d64d3fdadefe1d39e62727567a 100644 (file)
@@ -465,3 +465,12 @@ $cfg->setConfigEntry('thousands_separator', '.');
 
 // CFG: DECIMALS-SEPARATOR
 $cfg->setConfigEntry('decimals_separator', ',');
+
+// CFG: CRYPTO-MCRYPT-STREAM-CLASS
+$cfg->setConfigEntry('crypto_mcrypt_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\McryptStream');
+
+// CFG: CRYPTO-OPENSSL-STREAM-CLASS
+$cfg->setConfigEntry('crypto_openssl_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\OpenSslStream');
+
+// CFG: CRYPTO-NULL-STREAM-CLASS
+$cfg->setConfigEntry('crypto_null_stream_class', 'Org\Mxchange\CoreFramework\Stream\Crypto\NullCryptoStream');
index 4aa523abff7f94916c9068994787712aa8c7e8db..3f68e5b8571a3bf45148c484af31ecfea9dfd00f 100644 (file)
@@ -8,7 +8,6 @@ use Org\Mxchange\CoreFramework\Criteria\Criteria;
 use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
 use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria;
 use Org\Mxchange\CoreFramework\Crypto\Cryptable;
-use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
 use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper;
 use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
 use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory;
@@ -23,7 +22,6 @@ use Org\Mxchange\CoreFramework\Lists\Listable;
 use Org\Mxchange\CoreFramework\Loader\ClassLoader;
 use Org\Mxchange\CoreFramework\Localization\ManageableLanguage;
 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
-use Org\Mxchange\CoreFramework\Menu\RenderableMenu;
 use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Result\Database\CachedDatabaseResult;
@@ -107,11 +105,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         */
        private $userInstance = NULL;
 
-       /**
-        * Instance of a RNG
-        */
-       private $rngInstance = NULL;
-
        /**
         * Instance of a crypto helper
         */
@@ -127,16 +120,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
         */
        private $listInstance = NULL;
 
-       /**
-        * Instance of a menu
-        */
-       private $menuInstance = NULL;
-
-       /**
-        * Instance of the image
-        */
-       private $imageInstance = NULL;
-
        /**
         * A helper instance for the form
         */
@@ -653,25 +636,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
                return $this->userInstance;
        }
 
-       /**
-        * Setter for RNG instance
-        *
-        * @param       $rngInstance    An instance of a random number generator (RNG)
-        * @return      void
-        */
-       protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
-               $this->rngInstance = $rngInstance;
-       }
-
-       /**
-        * Getter for RNG instance
-        *
-        * @return      $rngInstance    An instance of a random number generator (RNG)
-        */
-       public final function getRngInstance () {
-               return $this->rngInstance;
-       }
-
        /**
         * Setter for Cryptable instance
         *
@@ -710,44 +674,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
                return $this->listInstance;
        }
 
-       /**
-        * Setter for the menu instance
-        *
-        * @param       $menuInstance   A RenderableMenu instance
-        * @return      void
-        */
-       protected final function setMenuInstance (RenderableMenu $menuInstance) {
-               $this->menuInstance = $menuInstance;
-       }
-
-       /**
-        * Getter for the menu instance
-        *
-        * @return      $menuInstance   A RenderableMenu instance
-        */
-       protected final function getMenuInstance () {
-               return $this->menuInstance;
-       }
-
-       /**
-        * Setter for image instance
-        *
-        * @param       $imageInstance  An instance of an image
-        * @return      void
-        */
-       public final function setImageInstance (BaseImage $imageInstance) {
-               $this->imageInstance = $imageInstance;
-       }
-
-       /**
-        * Getter for image instance
-        *
-        * @return      $imageInstance  An instance of an image
-        */
-       public final function getImageInstance () {
-               return $this->imageInstance;
-       }
-
        /**
         * Setter for DatabaseWrapper instance
         *
index 96eb2f9dd7191adbc5f7ec46f636131debfb5ffd..7ef8d3f3adab43aab9ab033cf5e0a86f2ef3fd35 100644 (file)
@@ -5,6 +5,7 @@ namespace Org\Mxchange\CoreFramework\Helper\Crypto;
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Crypto\Cryptable;
+use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
 
@@ -50,6 +51,11 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
         */
        private $salt = '';
 
+       /**
+        * Instance of a RNG
+        */
+       private $rngInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -95,6 +101,25 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                return self::$selfInstance;
        }
 
+       /**
+        * Setter for RNG instance
+        *
+        * @param       $rngInstance    An instance of a random number generator (RNG)
+        * @return      void
+        */
+       protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
+               $this->rngInstance = $rngInstance;
+       }
+
+       /**
+        * Getter for RNG instance
+        *
+        * @return      $rngInstance    An instance of a random number generator (RNG)
+        */
+       public final function getRngInstance () {
+               return $this->rngInstance;
+       }
+
        /**
         * Attaches a crypto stream to this crypto helper by detecting loaded
         * modules.
@@ -106,13 +131,13 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable {
                // Do we have openssl/mcrypt loaded?
                if ($this->isPhpExtensionLoaded('mcrypt')) {
                        // Then use it
-                       $this->cryptoStreamInstance = ObjectFactory::createObjectByName('Org\Mxchange\CoreFramework\Stream\Crypto\McryptStream', array($this->getRngInstance()));
+                       $this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_mcrypt_stream_class', array($this->getRngInstance()));
                } elseif ($this->isPhpExtensionLoaded('openssl')) {
                        // Then use it
-                       $this->cryptoStreamInstance = ObjectFactory::createObjectByName('Org\Mxchange\CoreFramework\Stream\Crypto\OpenSslStream', array($this->getRngInstance()));
+                       $this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_openssl_stream_class', array($this->getRngInstance()));
                } else {
                        // If nothing works ...
-                       $this->cryptoStreamInstance = ObjectFactory::createObjectByName('Org\Mxchange\CoreFramework\Stream\Crypto\NullCryptoStream');
+                       $this->cryptoStreamInstance = ObjectFactory::createObjectByConfiguredName('crypto_null_stream_class');
                }
        }
 
index 89dd8bc086eddb9a8bc6b0e42de388000851b0a1..8005d064591ae9c49570d8880581d6f235ba801b 100644 (file)
@@ -3,6 +3,7 @@
 namespace Org\Mxchange\CoreFramework\Helper\Captcha;
 
 // Import framework stuff
+use Org\Mxchange\CoreFramework\Crypto\RandomNumber\RandomNumberGenerator;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
 use Org\Mxchange\CoreFramework\Helper\BaseHelper;
@@ -30,6 +31,11 @@ use Org\Mxchange\CoreFramework\Helper\BaseHelper;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseCaptcha extends BaseHelper {
+       /**
+        * Instance of a RNG
+        */
+       private $rngInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -41,6 +47,25 @@ abstract class BaseCaptcha extends BaseHelper {
                parent::__construct($className);
        }
 
+       /**
+        * Setter for RNG instance
+        *
+        * @param       $rngInstance    An instance of a random number generator (RNG)
+        * @return      void
+        */
+       protected final function setRngInstance (RandomNumberGenerator $rngInstance) {
+               $this->rngInstance = $rngInstance;
+       }
+
+       /**
+        * Getter for RNG instance
+        *
+        * @return      $rngInstance    An instance of a random number generator (RNG)
+        */
+       public final function getRngInstance () {
+               return $this->rngInstance;
+       }
+
        /**
         * Initializes the random number generator (RNG)
         *
index 8be1d27c4da8dc830525265d69f9ac58f9bb73e8..e6b7eff04fe5962838fe6961cfb795de89d50e3c 100644 (file)
@@ -4,6 +4,7 @@ namespace Org\Mxchange\CoreFramework\Response;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Image\BaseImage;
 use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Response\Responseable;
@@ -34,6 +35,11 @@ use Org\Mxchange\CoreFramework\Response\Responseable;
  * Michal Cihar <michal@cihar.com>, licensed under GNU GPL 2.0.
  */
 class ImageResponse extends BaseResponse implements Responseable {
+       /**
+        * Instance of the image
+        */
+       private $imageInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -60,6 +66,25 @@ class ImageResponse extends BaseResponse implements Responseable {
                return $responseInstance;
        }
 
+       /**
+        * Setter for image instance
+        *
+        * @param       $imageInstance  An instance of an image
+        * @return      void
+        */
+       public final function setImageInstance (BaseImage $imageInstance) {
+               $this->imageInstance = $imageInstance;
+       }
+
+       /**
+        * Getter for image instance
+        *
+        * @return      $imageInstance  An instance of an image
+        */
+       public final function getImageInstance () {
+               return $this->imageInstance;
+       }
+
        /**
         * Initializes the template engine instance
         *
index 855744872c939d714f660d7227e8e486f6825aa3..e213c6a7a32271bfb651ddb19d10431b1d5acbd6 100644 (file)
@@ -6,6 +6,7 @@ namespace Org\Mxchange\CoreFramework\Template\Engine;
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Image\BaseImage;
 use Org\Mxchange\CoreFramework\Parser\Xml\XmlParser;
 use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
 use Org\Mxchange\CoreFramework\Response\Responseable;
@@ -74,6 +75,11 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
         */
        private $currMainNode = '';
 
+       /**
+        * Instance of the image
+        */
+       private $imageInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -163,6 +169,25 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
                return $this->subNodes;
        }
 
+       /**
+        * Setter for image instance
+        *
+        * @param       $imageInstance  An instance of an image
+        * @return      void
+        */
+       public final function setImageInstance (BaseImage $imageInstance) {
+               $this->imageInstance = $imageInstance;
+       }
+
+       /**
+        * Getter for image instance
+        *
+        * @return      $imageInstance  An instance of an image
+        */
+       public final function getImageInstance () {
+               return $this->imageInstance;
+       }
+
        /**
         * Handles the start element of an XML resource
         *
@@ -220,7 +245,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
                }
 
                // Construct method name
-               $methodName = 'finish' . StringUtils::convertToClassName($nodeName);
+               $methodName = sprintf('finish%s', StringUtils::convertToClassName($nodeName));
 
                // Call the corresponding method
                call_user_func_array(array($this->getImageInstance(), $methodName), array());
@@ -499,6 +524,7 @@ class ImageTemplateEngine extends BaseTemplateEngine implements CompileableTempl
         *
         * @param       $responseInstance       An instance of a Responseable class
         * @return      void
+        * @todo        Nothing to really "transfer" here?
         */
        public function transferToResponse (Responseable $responseInstance) {
                // Set the image instance
index 39177f1d9a06b2dc79a1b4a4c95cc26c69731a1a..67fdedb9a7dd658ff290ff7053d3e89b417bc873 100644 (file)
@@ -113,11 +113,6 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         */
        private $menuBlocks = array();
 
-       /**
-        * Menu instance
-        */
-       private $menuInstance = NULL;
-
        /**
         * Current main node
         */
@@ -128,6 +123,11 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
         */
        private $dependencyContent = array();
 
+       /**
+        * Instance of a menu
+        */
+       private $menuInstance = NULL;
+
        /**
         * Protected constructor
         *
@@ -199,6 +199,25 @@ class MenuTemplateEngine extends BaseTemplateEngine implements CompileableTempla
                return $templateInstance;
        }
 
+       /**
+        * Setter for the menu instance
+        *
+        * @param       $menuInstance   A RenderableMenu instance
+        * @return      void
+        */
+       protected final function setMenuInstance (RenderableMenu $menuInstance) {
+               $this->menuInstance = $menuInstance;
+       }
+
+       /**
+        * Getter for the menu instance
+        *
+        * @return      $menuInstance   A RenderableMenu instance
+        */
+       private final function getMenuInstance () {
+               return $this->menuInstance;
+       }
+
        /**
         * Load a specified menu template into the engine
         *