]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/feature/class_FrameworkFeature.php
Continued:
[core.git] / framework / main / classes / feature / class_FrameworkFeature.php
index 84410bc36505fab91dcf50394fb0e412809b3a8c..27227aa1ec63257fe12ed9efde0a12120a1a2c27 100644 (file)
@@ -7,6 +7,7 @@ use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
 use Org\Mxchange\CoreFramework\Loader\NoClassException;
 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
 
 /**
  * The general feature management class. No instance is needed as this class
@@ -14,7 +15,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -54,7 +55,7 @@ class FrameworkFeature extends BaseFrameworkSystem {
         *     'instance'     => NULL
         * )
         */
-       private static $enabledFeatures = array();
+       private static $enabledFeatures = [];
 
        /**
         * Protected constructor
@@ -98,10 +99,8 @@ class FrameworkFeature extends BaseFrameworkSystem {
         * @return      $isAvailable    Whether the given feature is available
         */
        public static function isFeatureAvailable ($featureName) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: featureName=%s - CALLED!', __METHOD__, __LINE__, $featureName));
-
                // Is the cache set?
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s - CALLED!', $featureName));
                if (!isset(self::$enabledFeatures[$featureName]['is_available'])) {
                        // Default is not available
                        self::$enabledFeatures[$featureName]['is_available'] = false;
@@ -110,17 +109,15 @@ class FrameworkFeature extends BaseFrameworkSystem {
                        // Is the feature enabled?
                        if (!self::isFeatureEnabled($featureName)) {
                                // Then it can't be available
-                               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: Feature "%s"is not enabled.', __METHOD__, __LINE__, $featureName));
+                               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: Feature "%s"is not enabled.', $featureName));
                                return false;
                        } // END - if
 
                        // Create config key (for feature class lookup)
                        $configKey = sprintf('feature_%s_class', $featureName);
 
-                       // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: configKey=%s', __METHOD__, __LINE__, $configKey));
-
                        // Now try to get the instance
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: configKey=%s', $configKey));
                        try {
                                // Try to get an instance
                                self::$enabledFeatures[$featureName]['instance'] = ObjectFactory::createObjectByConfiguredName($configKey);
@@ -129,14 +126,12 @@ class FrameworkFeature extends BaseFrameworkSystem {
                                self::$enabledFeatures[$featureName]['is_available'] = self::$enabledFeatures[$featureName]['instance']->isFeatureAvailable();
                        } catch (NoClassException $e) {
                                // Feature class not found
-                               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: Feature "%s"is not available due to missing feature class. Disabling feature ...', __METHOD__, __LINE__, $featureName));
+                               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: Feature "%s"is not available due to missing feature class. Disabling feature ...', $featureName));
                        }
                } // END - if
 
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d]: featureName=%s,isAvailable=%d - EXIT!', __METHOD__, __LINE__, $featureName, intval(self::$enabledFeatures[$featureName]['is_available'])));
-
                // Return "cached" status
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s,isAvailable=%d - EXIT!', $featureName, intval(self::$enabledFeatures[$featureName]['is_available'])));
                return self::$enabledFeatures[$featureName]['is_available'];
        }
 
@@ -156,10 +151,14 @@ class FrameworkFeature extends BaseFrameworkSystem {
                 * Please make sure that isFeatureAvailable() has been called and it has
                 * returned true before calling this method.
                 */
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: featureName=%s,featureMethod=%s,args[]=%s - CALLED!', $featureName, $featureMethod, gettype($args)));
                assert(self::isFeatureAvailable($featureName));
 
                // Array for call-back
-               $callable = array(self::$enabledFeatures[$featureName]['instance'], 'featureMethod' . self::convertToClassName($featureMethod));
+               $callable = array(
+                       self::$enabledFeatures[$featureName]['instance'],
+                       sprintf('featureMethod%s', StringUtils::convertToClassName($featureMethod))
+               );
 
                // So is the feature's method callable?
                if (!is_callable($callable)) {
@@ -171,6 +170,7 @@ class FrameworkFeature extends BaseFrameworkSystem {
                $return = call_user_func_array($callable, $args);
 
                // Return any returned value
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FRAMEWORK-FEATURE: return[]=%s - EXIT!', gettype($return)));
                return $return;
        }