*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
- * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software
* @license GNU GPL 3.0 or any newer version
* @link http://www.ship-simu.org
*
* 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 {
/**
- * Private constructor
+ * Protected constructor
*
* @return void
*/
protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
+ }
+
+ /**
+ * 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);
- // Set part description
- $this->setObjectDescription("Ein spezieller Controller");
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
- // Create unique ID number
- $this->createUniqueID();
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
- // Clean up a little
- $this->removeSystemArray();
+ // Flush the response out
+ $responseInstance->flushBuffer();
}
}