00001 <?php 00024 class WebDoFormController extends BaseController implements Controller { 00030 protected function __construct () { 00031 // Call parent constructor 00032 parent::__construct(__CLASS__); 00033 } 00034 00041 public final static function createWebDoFormController (CommandResolver $resolverInstance) { 00042 // Create the instance 00043 $controllerInstance = new WebDoFormController(); 00044 00045 // Set resolver instance 00046 $controllerInstance->setResolverInstance($resolverInstance); 00047 00048 // We need the controller instance in resolver class so set it here 00049 $resolverInstance->setControllerInstance($controllerInstance); 00050 00051 // Return the prepared instance 00052 return $controllerInstance; 00053 } 00054 00062 public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) { 00063 // Get the "form action" 00064 $formAction = $requestInstance->getRequestElement('form'); 00065 00066 // Get command instance from resolver 00067 $commandInstance = $this->getResolverInstance()->resolveCommand($formAction); 00068 00069 // Add more filters by the command 00070 $commandInstance->addExtraFilters($this, $requestInstance); 00071 00072 // Try to run the pre filters, if auth exceptions come through redirect here 00073 try { 00074 // Run the pre filters 00075 $this->executePreFilters($requestInstance, $responseInstance); 00076 } catch (UserAuthorizationException $e) { 00077 // Redirect to main page 00078 $responseInstance->redirectToConfiguredUrl('login_failed_url'); 00079 00080 // Exit here 00081 exit(); 00082 } 00083 00084 // Is the request still valid? Post filters shall only be executed of 00085 // the request is valid 00086 if ($requestInstance->isRequestValid()) { 00087 // Execute the command 00088 $commandInstance->execute($requestInstance, $responseInstance); 00089 00090 // Execute *very* generic ppost filters 00091 $this->executePostFilters($requestInstance, $responseInstance); 00092 } 00093 00094 // Flush the buffer out 00095 $responseInstance->flushBuffer(); 00096 } 00097 } 00098 00099 // [EOF] 00100 ?>
1.5.6