Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 11 Apr 2018 04:33:01 +0000 (06:33 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 11 Apr 2018 04:33:01 +0000 (06:33 +0200)
- 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 <roland@mxchange.org>
14 files changed:
application/tests/class_ApplicationHelper.php
framework/bootstrap/class_FrameworkBootstrap.php
framework/main/classes/application/class_BaseApplication.php
framework/main/classes/class_BaseFrameworkSystem.php
framework/main/classes/mailer/debug/class_DebugMailer.php
framework/main/classes/resolver/action/html/class_HtmlActionResolver.php
framework/main/classes/resolver/command/console/class_ConsoleCommandResolver.php
framework/main/classes/resolver/command/html/class_HtmlCommandResolver.php
framework/main/classes/resolver/command/image/class_ImageCommandResolver.php
framework/main/classes/resolver/controller/console/class_ConsoleControllerResolver.php
framework/main/classes/resolver/controller/html/class_HtmlControllerResolver.php
framework/main/classes/resolver/controller/image/class_ImageControllerResolver.php
framework/main/tests/resolver/command/console/class_TestsConsoleCommandResolver.php
framework/main/tests/resolver/controller/class_TestsConsoleControllerResolver.php

index eab5a2c..007ed66 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
  */
-class ApplicationHelper extends BaseFrameworkSystem implements ManageableApplication, Registerable {
+class ApplicationHelper extends BaseApplication implements ManageableApplication, Registerable {
        /**
         * The version number of this application
         */
index 26c419d..d7379e5 100644 (file)
@@ -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
index ea60fb1..3a6f8e6 100644 (file)
@@ -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);
        }
 
 }
index 07e0e60..5875c00 100644 (file)
@@ -876,26 +876,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac
        }
 
        /**
-        * 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
         *
         * @return      $langInstance   An instance to the language sub-system
index c9292dd..40b67c6 100644 (file)
@@ -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();
index 38040fd..ee1d601 100644 (file)
@@ -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;
        }
index 2a12036..191f6d5 100644 (file)
@@ -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;
        }
index df9262a..93c04fe 100644 (file)
@@ -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;
        }
index 9e642c3..a041d1d 100644 (file)
@@ -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;
        }
index 7292959..d8db5dc 100644 (file)
@@ -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);
 
index cbc46d0..1918950 100644 (file)
@@ -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);
 
index 0202424..91ed2cc 100644 (file)
@@ -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);
 
index b4a3314..9d61d50 100644 (file)
@@ -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;
index c1e5f99..62c2540 100644 (file)
@@ -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);