]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/controller/class_
Image controller/resolver and fixes:
[shipsimu.git] / inc / classes / main / controller / class_
index 46459d5d8a374b08a709b32a7cdd085216df77f5..d9c2a19a28b33c081827a66d89f3ede7dfd2bfa5 100644 (file)
@@ -21,7 +21,7 @@
  * 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 Controller extends BaseController implements Controller {
+class ???Controller extends BaseController implements Controller {
        /**
         * Protected constructor
         *
@@ -32,13 +32,48 @@ class Controller extends BaseController implements Controller {
                parent::__construct(__CLASS__);
 
                // Set part description
-               $this->setObjectDescription("Ein spezieller Controller");
+               $this->setObjectDescription("");
 
                // Create unique ID number
                $this->generateUniqueId();
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $resolverInstance               An instance of a command resolver class
+        * @return      $controllerInstance             A prepared instance of this class
+        */
+       public final static function create???Controller (CommandResolver $resolverInstance) {
+               // Create the instance
+               $controllerInstance = new ???Controller();
+
+               // Set the command resolver
+               $controllerInstance->setResolverInstance($resolverInstance);
+
+               // Return the prepared instance
+               return $controllerInstance;
+       }
+
+       /**
+        * Handles the given request and response
+        *
+        * @param       $requestInstance        An instance of a request class
+        * @param       $responseInstance       An instance of a response class
+        * @return      void
+        */
+       public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+               // Get the command instance
+               $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+               // This request was valid! :-D
+               $requestInstance->requestIsValid();
+
+               // Execute the command
+               $commandInstance->execute($requestInstance, $responseInstance);
 
-               // Clean up a little
-               $this->removeSystemArray();
+               // Flush the response out
+               $responseInstance->flushBuffer();
        }
 }