]> git.mxchange.org Git - core.git/commitdiff
Introduced executeGenericPrePostCommand() which will execute a command with
authorRoland Haeder <roland@mxchange.org>
Sun, 5 Apr 2015 22:30:50 +0000 (00:30 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 5 Apr 2015 22:30:50 +0000 (00:30 +0200)
pre and post filters.

Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/main/controller/captcha/class_ImageCodeCaptchaController.php
inc/classes/main/controller/class_BaseController.php
inc/classes/main/controller/console/class_ConsoleDefaultNewsController.php
inc/classes/main/controller/html/class_Html
inc/classes/main/controller/html/class_HtmlConfirmController.php
inc/classes/main/controller/html/class_HtmlDefaultNewsController.php
inc/classes/main/controller/html/class_HtmlLoginController.php
inc/classes/main/controller/html/class_HtmlLogoutDoneController.php
inc/classes/main/controller/html/class_HtmlProblemController.php
inc/classes/main/controller/html/class_HtmlRegisterController.php

index d9a3f33176dd5c6e3c6e97c31841a9963b4f0e3c..99b044e93db5d25035288f329d95eb1c38461811 100644 (file)
@@ -60,23 +60,8 @@ class ImageCodeCaptchaController extends BaseController implements Controller {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Execute pre filters
-               $this->executePreFilters($requestInstance, $responseInstance);
-
-               // Get the command instance
-               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
-               // This request was valid! :-D
-               $requestInstance->requestIsValid();
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Execute post filters
-               $this->executePostFilters($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushBuffer();
+               // Generic pre-post command execution
+               $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
        }
 }
 
index e604b54c977ce53bfd468a77dd73ab5bed6da882..3b0d24c18cd3f878fdd0880b07bc4448fcea3209 100644 (file)
@@ -54,6 +54,36 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
                Registry::getRegistry()->addInstance('controller', $this);
        }
 
+       /**
+        * Executes a command with pre and post filters
+        *
+        * @param       $requestInstance        A Requestable class
+        * @param       $responseInstance       A Responseable class
+        * @return      void
+        */
+       public function executeGenericPrePostCommand (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get the command instance from the resolver by sending a request instance to the resolver
+               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+               // Add more filters by the command
+               $commandInstance->addExtraFilters($this, $requestInstance);
+
+               // Run the pre filters
+               $this->executePreFilters($requestInstance, $responseInstance);
+
+               // This request was valid! :-D
+               $requestInstance->requestIsValid();
+
+               // Execute the command
+               $commandInstance->execute($requestInstance, $responseInstance);
+
+               // Run the post filters
+               $this->executePostFilters($requestInstance, $responseInstance);
+
+               // Flush the response out
+               $responseInstance->flushBuffer();
+       }
+
        /**
         * Private method to initialize a given filter chain
         *
@@ -110,6 +140,16 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
                $this->addFilter(self::FILTER_CHAIN_POST_COMMAND, $filterInstance);
        }
 
+       /**
+        * Add a shutdown filter
+        *
+        * @param       $filterInstance         A Filterable class
+        * @return      void
+        */
+       public function addShutdownFilter (Filterable $filterInstance) {
+               $this->addFilter('shutdown', $filterInstance);
+       }
+
        /**
         * Executes given filter chain chain
         *
@@ -154,16 +194,6 @@ class BaseController extends BaseFrameworkSystem implements Registerable {
                $this->executeFilters(self::FILTER_CHAIN_POST_COMMAND, $requestInstance, $responseInstance);
        }
 
-       /**
-        * Add a shutdown filter
-        *
-        * @param       $filterInstance         A Filterable class
-        * @return      void
-        */
-       public function addShutdownFilter (Filterable $filterInstance) {
-               $this->addFilter('shutdown', $filterInstance);
-       }
-
        /**
         * Executes all shutdown filters
         *
index f0c029739f0ca06d4d845d4e2578f6f340a40219..89ecb683cdd4c92232e398da801a8bd5c3e05bf4 100644 (file)
@@ -61,26 +61,8 @@ class ConsoleDefaultNewsController extends BaseController implements Controller
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
-               // Add more filters by the command
-               $commandInstance->addExtraFilters($this, $requestInstance);
-
-               // Run the pre filters
-               $this->executePreFilters($requestInstance, $responseInstance);
-
-               // This request was valid! :-D
-               $requestInstance->requestIsValid();
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Run the pre filters
-               $this->executePostFilters($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushBuffer();
+               // Generic pre-post command execution
+               $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
        }
 }
 
index 6d3708f356fe2df254d7cd4024ab788d59c78e69..e9a95a4ddcd26f24cb3bb5fb08120d2a48ec9c17 100644 (file)
@@ -61,23 +61,8 @@ class Html???Controller extends BaseController implements Controller {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
-               // Run the pre filters
-               $this->executePreFilters($requestInstance, $responseInstance);
-
-               // This request was valid! :-D
-               $requestInstance->requestIsValid();
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Run the post filters
-               $this->executePostFilters($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushBuffer();
+               // Generic pre-post command execution
+               $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
        }
 }
 
index 8e3147e2c2b16af00b755672e090c05ca50b27ae..ea3e7633846582f0e577feda9692b0a79ac08517 100644 (file)
@@ -64,23 +64,8 @@ class HtmlConfirmController extends BaseController implements Controller {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
-               // Run the pre filters
-               $this->executePreFilters($requestInstance, $responseInstance);
-
-               // This request was valid! :-D
-               $requestInstance->requestIsValid();
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Run the post filters
-               $this->executePostFilters($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushBuffer();
+               // Generic pre-post command execution
+               $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
        }
 }
 
index 36b0b96b3cb76b99628b50d4c4a8c2651e1bb6bf..1d346b8a37f5c22f41fd7e6d6cc379058ed8f65a 100644 (file)
@@ -61,26 +61,8 @@ class HtmlDefaultNewsController extends BaseController implements Controller {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
-               // Add more filters by the command
-               $commandInstance->addExtraFilters($this, $requestInstance);
-
-               // Run the pre filters
-               $this->executePreFilters($requestInstance, $responseInstance);
-
-               // This request was valid! :-D
-               $requestInstance->requestIsValid();
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Run the post filters
-               $this->executePostFilters($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushBuffer();
+               // Generic pre-post command execution
+               $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
        }
 }
 
index eef5b5ee00d6848ac0410a4189039d4815e65f72..0db76a7570e55ce4d4517b92f372aad464c4c65d 100644 (file)
@@ -59,26 +59,8 @@ class HtmlLoginController extends BaseController implements Controller {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-               // Add more filters by the command
-               $commandInstance->addExtraFilters($this, $requestInstance);
-
-               // Run the pre filters
-               $this->executePreFilters($requestInstance, $responseInstance);
-
-               // This request was valid! :-D
-               $requestInstance->requestIsValid();
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Run the post filters
-               $this->executePostFilters($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushBuffer();
+               // Generic pre-post command execution
+               $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
        }
 }
 
index 4f6f98be79a0cf1c1cf21a5f1469f3cf32fb2497..b2f93a196248acd6f00e9ab9aefe3ac3fc7dfa98 100644 (file)
@@ -58,26 +58,8 @@ class HtmlLogoutDoneController extends BaseController implements Controller {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
-               // Add more filters by the command
-               $commandInstance->addExtraFilters($this, $requestInstance);
-
-               // Run the pre filters
-               $this->executePreFilters($requestInstance, $responseInstance);
-
-               // This request was valid! :-D
-               $requestInstance->requestIsValid();
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Run the post filters
-               $this->executePostFilters($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushBuffer();
+               // Generic pre-post command execution
+               $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
        }
 }
 
index 3a1551c61f98d80713c71cd5fae5b843b82ebac3..f3c37356c1692ce8e8b03a22bf7cf538bf4d21e4 100644 (file)
@@ -58,26 +58,8 @@ class HtmlProblemController extends BaseController implements Controller {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
-               // Add more filters by the command
-               $commandInstance->addExtraFilters($this, $requestInstance);
-
-               // Run the pre filters
-               $this->executePreFilters($requestInstance, $responseInstance);
-
-               // This request was valid! :-D
-               $requestInstance->requestIsValid();
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Run the post filters
-               $this->executePostFilters($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushBuffer();
+               // Generic pre-post command execution
+               $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
        }
 }
 
index 0c9579035c884af3a5460bc3b3b54f09bd4b4e97..b1d5999ae320609280d7a3ca054373f494bbd885 100644 (file)
@@ -58,26 +58,8 @@ class HtmlRegisterController extends BaseController implements Controller {
         * @return      void
         */
        public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
-               // Get the command instance from the resolver by sending a request instance to the resolver
-               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
-               // Add more filters by the command
-               $commandInstance->addExtraFilters($this, $requestInstance);
-
-               // Run the pre filters
-               $this->executePreFilters($requestInstance, $responseInstance);
-
-               // This request was valid! :-D
-               $requestInstance->requestIsValid();
-
-               // Execute the command
-               $commandInstance->execute($requestInstance, $responseInstance);
-
-               // Run the post filters
-               $this->executePostFilters($requestInstance, $responseInstance);
-
-               // Flush the response out
-               $responseInstance->flushBuffer();
+               // Generic pre-post command execution
+               $this->executeGenericPrePostCommand($requestInstance, $responseInstance);
        }
 }