From: Roland Häder Date: Wed, 11 Apr 2018 04:33:01 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e137daa3a06f4b9e3767db913854c609383e8533;p=core.git Continued: - ApplicationHelper needs to expand BaseApplication to have "self-registration" generically done - so no more need to register 'application' instance everywhere else, just here Signed-off-by: Roland Häder --- diff --git a/application/tests/class_ApplicationHelper.php b/application/tests/class_ApplicationHelper.php index eab5a2c7..007ed669 100644 --- a/application/tests/class_ApplicationHelper.php +++ b/application/tests/class_ApplicationHelper.php @@ -3,12 +3,11 @@ namespace Org\Mxchange\CoreFramework\Helper\Application; // Import framework stuff +use Org\Mxchange\CoreFramework\Application\BaseApplication; use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Loader\ClassLoader; use Org\Mxchange\CoreFramework\Manager\ManageableApplication; -use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; -use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Template\CompileableTemplate; @@ -51,7 +50,7 @@ use Org\Mxchange\CoreFramework\Template\CompileableTemplate; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplication, Registerable { +class ApplicationHelper extends BaseApplication implements ManageableApplication, Registerable { /** * The version number of this application */ diff --git a/framework/bootstrap/class_FrameworkBootstrap.php b/framework/bootstrap/class_FrameworkBootstrap.php index 26c419da..d7379e5b 100644 --- a/framework/bootstrap/class_FrameworkBootstrap.php +++ b/framework/bootstrap/class_FrameworkBootstrap.php @@ -362,9 +362,6 @@ final class FrameworkBootstrap { )); } - // Set it in registry - GenericRegistry::getRegistry()->addInstance('application', $applicationInstance); - // Now call all methods in one go foreach (array('setupApplicationData', 'initApplication', 'launchApplication') as $methodName) { // Debug message diff --git a/framework/main/classes/application/class_BaseApplication.php b/framework/main/classes/application/class_BaseApplication.php index ea60fb1c..3a6f8e6a 100644 --- a/framework/main/classes/application/class_BaseApplication.php +++ b/framework/main/classes/application/class_BaseApplication.php @@ -39,11 +39,8 @@ abstract class BaseApplication extends BaseFrameworkSystem { // Call parent constructor parent::__construct($className); - // Get registry instance - $registryInstance = GenericRegistry::getRegistry(); - - // Add this instance - $registryInstance->addInstance('application', $this); + // Set this instance as application instance + GenericRegistry::getRegistry()->addInstance('application', $this); } } diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 07e0e601..5875c00f 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -875,26 +875,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac return $compressorInstance; } - /** - * Protected getter for a manageable application helper class - * - * @return $applicationInstance An instance of a manageable application helper class - */ - protected final function getApplicationInstance () { - $applicationInstance = GenericRegistry::getRegistry()->getInstance('application'); - return $applicationInstance; - } - - /** - * Setter for a manageable application helper class - * - * @param $applicationInstance An instance of a manageable application helper class - * @return void - */ - public final function setApplicationInstance (ManageableApplication $applicationInstance) { - GenericRegistry::getRegistry()->addInstance('application', $applicationInstance); - } - /** * Private getter for language instance * diff --git a/framework/main/classes/mailer/debug/class_DebugMailer.php b/framework/main/classes/mailer/debug/class_DebugMailer.php index c9292dda..40b67c6c 100644 --- a/framework/main/classes/mailer/debug/class_DebugMailer.php +++ b/framework/main/classes/mailer/debug/class_DebugMailer.php @@ -61,9 +61,6 @@ class DebugMailer extends BaseMailer implements DeliverableMail { // Set template instance $mailerInstance->setTemplateInstance($templateInstance); - // Set application instance - $mailerInstance->setApplicationInstance($applicationInstance); - // Set template name $mailerInstance->setTemplateName($templateName); @@ -176,8 +173,11 @@ class DebugMailer extends BaseMailer implements DeliverableMail { $templateInstance->compileTemplate(); $templateInstance->assignTemplateWithVariable('footer', 'footer'); + // Get master template name + $masterTemplateName = GenericRegistry::getRegistry()->getInstance('application')->buildMasterTemplateName(); + // Load the master template - $templateInstance->loadCodeTemplate(GenericRegistry::getRegistry()->getInstance('application')->buildMasterTemplateName()); + $templateInstance->loadCodeTemplate($masterTemplateName); // Then compile it again $templateInstance->compileVariables(); diff --git a/framework/main/classes/resolver/action/html/class_HtmlActionResolver.php b/framework/main/classes/resolver/action/html/class_HtmlActionResolver.php index 38040fd4..ee1d601c 100644 --- a/framework/main/classes/resolver/action/html/class_HtmlActionResolver.php +++ b/framework/main/classes/resolver/action/html/class_HtmlActionResolver.php @@ -72,9 +72,6 @@ class HtmlActionResolver extends BaseActionResolver implements ActionResolver { throw new InvalidActionException(array($resolverInstance, $actionName), self::EXCEPTION_INVALID_ACTION); } - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - // Return the prepared instance return $resolverInstance; } diff --git a/framework/main/classes/resolver/command/console/class_ConsoleCommandResolver.php b/framework/main/classes/resolver/command/console/class_ConsoleCommandResolver.php index 2a12036e..191f6d59 100644 --- a/framework/main/classes/resolver/command/console/class_ConsoleCommandResolver.php +++ b/framework/main/classes/resolver/command/console/class_ConsoleCommandResolver.php @@ -69,9 +69,6 @@ class ConsoleCommandResolver extends BaseCommandResolver implements CommandResol throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); } - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - // Return the prepared instance return $resolverInstance; } diff --git a/framework/main/classes/resolver/command/html/class_HtmlCommandResolver.php b/framework/main/classes/resolver/command/html/class_HtmlCommandResolver.php index df9262af..93c04fe2 100644 --- a/framework/main/classes/resolver/command/html/class_HtmlCommandResolver.php +++ b/framework/main/classes/resolver/command/html/class_HtmlCommandResolver.php @@ -73,9 +73,6 @@ class HtmlCommandResolver extends BaseCommandResolver implements CommandResolver throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); } - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - // Return the prepared instance return $resolverInstance; } diff --git a/framework/main/classes/resolver/command/image/class_ImageCommandResolver.php b/framework/main/classes/resolver/command/image/class_ImageCommandResolver.php index 9e642c38..a041d1d8 100644 --- a/framework/main/classes/resolver/command/image/class_ImageCommandResolver.php +++ b/framework/main/classes/resolver/command/image/class_ImageCommandResolver.php @@ -72,9 +72,6 @@ class ImageCommandResolver extends BaseCommandResolver implements CommandResolve throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); } - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - // Return the prepared instance return $resolverInstance; } diff --git a/framework/main/classes/resolver/controller/console/class_ConsoleControllerResolver.php b/framework/main/classes/resolver/controller/console/class_ConsoleControllerResolver.php index 72929591..d8db5dc3 100644 --- a/framework/main/classes/resolver/controller/console/class_ConsoleControllerResolver.php +++ b/framework/main/classes/resolver/controller/console/class_ConsoleControllerResolver.php @@ -73,9 +73,6 @@ class ConsoleControllerResolver extends BaseControllerResolver implements Contro throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); } - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - // Set controller name $resolverInstance->setControllerName($controllerName); diff --git a/framework/main/classes/resolver/controller/html/class_HtmlControllerResolver.php b/framework/main/classes/resolver/controller/html/class_HtmlControllerResolver.php index cbc46d0b..19189506 100644 --- a/framework/main/classes/resolver/controller/html/class_HtmlControllerResolver.php +++ b/framework/main/classes/resolver/controller/html/class_HtmlControllerResolver.php @@ -73,9 +73,6 @@ class HtmlControllerResolver extends BaseControllerResolver implements Controlle throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); } - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - // Set controller name $resolverInstance->setControllerName($controllerName); diff --git a/framework/main/classes/resolver/controller/image/class_ImageControllerResolver.php b/framework/main/classes/resolver/controller/image/class_ImageControllerResolver.php index 02024241..91ed2ccb 100644 --- a/framework/main/classes/resolver/controller/image/class_ImageControllerResolver.php +++ b/framework/main/classes/resolver/controller/image/class_ImageControllerResolver.php @@ -73,9 +73,6 @@ class ImageControllerResolver extends BaseControllerResolver implements Controll throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); } - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - // Set controller name $resolverInstance->setControllerName($controllerName); diff --git a/framework/main/tests/resolver/command/console/class_TestsConsoleCommandResolver.php b/framework/main/tests/resolver/command/console/class_TestsConsoleCommandResolver.php index b4a33146..9d61d50a 100644 --- a/framework/main/tests/resolver/command/console/class_TestsConsoleCommandResolver.php +++ b/framework/main/tests/resolver/command/console/class_TestsConsoleCommandResolver.php @@ -69,9 +69,8 @@ class TestsConsoleCommandResolver extends BaseCommandResolver implements Command throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND); } - // Set namespace and application instance + // Set namespace for command $resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Command'); - $resolverInstance->setApplicationInstance($applicationInstance); // Return the prepared instance return $resolverInstance; diff --git a/framework/main/tests/resolver/controller/class_TestsConsoleControllerResolver.php b/framework/main/tests/resolver/controller/class_TestsConsoleControllerResolver.php index c1e5f999..62c25405 100644 --- a/framework/main/tests/resolver/controller/class_TestsConsoleControllerResolver.php +++ b/framework/main/tests/resolver/controller/class_TestsConsoleControllerResolver.php @@ -70,9 +70,6 @@ class TestsConsoleControllerResolver extends BaseControllerResolver implements C throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER); } - // Set the application instance - $resolverInstance->setApplicationInstance($applicationInstance); - // Set namespace and controller name $resolverInstance->setNamespace('Org\Mxchange\CoreFramework\Tests\Controller'); $resolverInstance->setControllerName($controllerName);