]> git.mxchange.org Git - core.git/commitdiff
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 eab5a2c70052e6465f7c54fa76c292b56657c3ec..007ed669e91123735b20ed343d3c7bd466505de6 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 26c419daf0dc42f1a124627a896c3e919e968338..d7379e5b76d747977c61763b93dcc8b8ab634bb2 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 ea60fb1c889ed7be3c9e3299a810b7b88b87c70c..3a6f8e6aeb85bbc260b1be6861ec484b8f0fce07 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 07e0e601029ac0ee6f8ddb11a8218136ec5238b6..5875c00ff59cc6220d010da70a3c8ad93a83f7fd 100644 (file)
@@ -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
         *
index c9292dda89d3ffa8e8d9a5b66aeb55f85d82162e..40b67c6cbaccd05323daa19e8b25cb306494831a 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 38040fd458faa4f5121502eff7c5a7dfde2ff279..ee1d601cce04aff607c626f77038a113f1809aca 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 2a12036ecc8af86f3adade35895ff2545484a805..191f6d59489e6ae2bd84900c121a2068d76e946e 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 df9262af0ba7d6e139bd9444e09a0a4dad029f75..93c04fe2608eb2bc2971b96bf3236d13c8147b7a 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 9e642c38979840d6229c4569af38c2295c1b05f6..a041d1d8b9866302891e60c6e0169dbf0f8f991f 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 729295919b74d2c864ebeb07824b16bffce126da..d8db5dc32c77ef2840bfb100e76f886f867e26a4 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 cbc46d0b961d29c8e1779dab6f166ba4ab733a52..19189506172eedb80916c7f13e40cf8a925f142e 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 02024241224bf99dfc97c9dcbd3a37f996f1bade..91ed2ccbd5b7f9e44c46ef20bd3d3fecb6abc42a 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 b4a33146ee81d23cff7ce5856277ddba0ca74ed1..9d61d50ae534c141804af45d423417036cc94e42 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 c1e5f999bf3e1703effaaf2ccdc9ac3734c92778..62c254053f5dbee06efad5db48db8e0b82320a34 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);