From: Roland Haeder Date: Sun, 26 Feb 2017 18:58:40 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6e0f0121a45058e64816ef6d1c621ba4218c1095;p=core.git Continued: - added generic test on loading classes configured in some_foo_class entries - now you can see, why "_class" must be set - added method getConfigurationArray() in FrameworkConfiguration which returns the whole configuration array ... - added "import" of XmlParser + fixed config entry with namespace - added "import" of BaseParser and Parseable Signed-off-by: Roland Häder --- diff --git a/framework/config.php b/framework/config.php index f389f4b5..89fd2f3c 100644 --- a/framework/config.php +++ b/framework/config.php @@ -266,7 +266,7 @@ $cfg->setConfigEntry('image_cmd_code_captcha_resolver_class', 'ImageCommandResol $cfg->setConfigEntry('mailer_class', 'DebugMailer'); // CFG: XML-PARSER-CLASS -$cfg->setConfigEntry('xml_parser_class', 'XmlParser'); +$cfg->setConfigEntry('xml_parser_class', 'CoreFramework\Parser\Xml\XmlParser'); // CFG: DECO-COMPACTING-XML-PARSER-CLASS $cfg->setConfigEntry('deco_compacting_xml_parser_class', 'XmlCompactorDecorator'); diff --git a/framework/config/class_FrameworkConfiguration.php b/framework/config/class_FrameworkConfiguration.php index ee7439e8..733ba9e1 100644 --- a/framework/config/class_FrameworkConfiguration.php +++ b/framework/config/class_FrameworkConfiguration.php @@ -209,6 +209,16 @@ class FrameworkConfiguration implements Registerable { ksort($this->config); } + /** + * Getter for whole configuration array + * + * @return $config Configuration array + */ + public final function getConfigurationArray () { + // Return it + return $this->config; + } + /** * Unset a configuration key, the entry must be there or else an * exception is thrown. diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 423fe296..71853092 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -20,6 +20,7 @@ use CoreFramework\Loader\ClassLoader; use CoreFramework\Manager\ManageableApplication; use CoreFramework\Middleware\Compressor\CompressorChannel; use CoreFramework\Middleware\Debug\DebugMiddleware; +use CoreFramework\Parser\Parseable; use CoreFramework\Registry\Register; use CoreFramework\Registry\Registry; use CoreFramework\Request\Requestable; diff --git a/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php b/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php index 152eb9fb..50fba45f 100644 --- a/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php +++ b/framework/main/classes/decorator/xml/class_XmlCompactorDecorator.php @@ -4,6 +4,7 @@ namespace CoreFramework\Parser\Xml; // Import framework stuff use CoreFramework\Factory\ObjectFactory; +use CoreFramework\Parser\Parseable; /** * A XML compacting decorator class for XML parsers diff --git a/framework/main/classes/parser/xml/class_XmlParser.php b/framework/main/classes/parser/xml/class_XmlParser.php index 318e344b..7a84119b 100644 --- a/framework/main/classes/parser/xml/class_XmlParser.php +++ b/framework/main/classes/parser/xml/class_XmlParser.php @@ -3,6 +3,8 @@ namespace CoreFramework\Parser\Xml; // Import framework stuff +use CoreFramework\Parser\BaseParser; +use CoreFramework\Parser\Parseable; use CoreFramework\Template\CompileableTemplate; /** diff --git a/framework/main/classes/template/image/class_ImageTemplateEngine.php b/framework/main/classes/template/image/class_ImageTemplateEngine.php index c438b049..950b8867 100644 --- a/framework/main/classes/template/image/class_ImageTemplateEngine.php +++ b/framework/main/classes/template/image/class_ImageTemplateEngine.php @@ -4,6 +4,7 @@ namespace CoreFramework\Template\Engine; // Import framework stuff use CoreFramework\Factory\ObjectFactory; +use CoreFramework\Parser\Xml\XmlParser; use CoreFramework\Registry\Registry; use CoreFramework\Response\Responseable; use CoreFramework\Template\CompileableTemplate; diff --git a/framework/main/classes/template/mail/class_MailTemplateEngine.php b/framework/main/classes/template/mail/class_MailTemplateEngine.php index 8f031a85..2c73e33c 100644 --- a/framework/main/classes/template/mail/class_MailTemplateEngine.php +++ b/framework/main/classes/template/mail/class_MailTemplateEngine.php @@ -3,6 +3,7 @@ namespace CoreFramework\Template\Engine; // Import framework stuff +use CoreFramework\Parser\Xml\XmlParser; use CoreFramework\Registry\Registry; use CoreFramework\Response\Responseable; use CoreFramework\Template\CompileableTemplate; diff --git a/framework/main/classes/template/menu/class_MenuTemplateEngine.php b/framework/main/classes/template/menu/class_MenuTemplateEngine.php index 64ab5b3c..6663f8ad 100644 --- a/framework/main/classes/template/menu/class_MenuTemplateEngine.php +++ b/framework/main/classes/template/menu/class_MenuTemplateEngine.php @@ -4,6 +4,7 @@ namespace CoreFramework\Template\Engine; // Import framework stuff use CoreFramework\Factory\ObjectFactory; +use CoreFramework\Parser\Xml\XmlParser; use CoreFramework\Registry\Registry; use CoreFramework\Template\CompileableTemplate; diff --git a/framework/main/tests/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php b/framework/main/tests/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php index 175f5173..b6f49a7a 100644 --- a/framework/main/tests/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php +++ b/framework/main/tests/filter/tests/configuration/classes/class_TestConfigurationLoadableClassesFilter.php @@ -8,6 +8,9 @@ use CoreFramework\Request\Requestable; use CoreFramework\Response\Responseable; use CoreFramework\Tests\Filter\BaseTestsFilter; +// Import SPL stuff +use \InvalidArgumentException; + /** * A LoadableClasses filter for tests * @@ -63,6 +66,39 @@ class TestConfigurationLoadableClassesFilter extends BaseTestsFilter implements * @todo 0% done */ public function execute (Requestable $requestInstance, Responseable $responseInstance) { + // Loop through all configuration keys + foreach ($this->getConfigInstance()->getConfigurationArray() as $configKey => $configValue) { + // Key must end with _class + if (substr($configKey, -6, 6) != '_class') { + // Skip this + continue; + } // END - if + + // Output message + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Testing configKey=%s,configValue[%s]=%s', $configKey, gettype($configValue), $configValue)); + + // This may throw exceptions + try { + // Is the class there? + if (!class_exists($configValue)) { + // Class not found + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" not found. FAILED', $configValue)); + + // Skip further tests + continue; + } // END - if + } catch (InvalidArgumentException $e) { + // Maybe not conform? + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" failed to load. Message: "%s"', $configValue, $e->getMessage())); + + // Skip further tests + continue; + } + + // class_exists() didn't fail + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('Class "%s" loaded successfully. OKAY', $configValue)); + } // END - foreach + // Implement this! $this->partialStub('Please implement this method.'); }