pre and post filters.
Signed-off-by: Roland Häder <roland@mxchange.org>
* @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);
}
}
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
*
$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
*
$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
*
* @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);
}
}
* @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);
}
}
* @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);
}
}
* @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);
}
}
* @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);
}
}
* @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);
}
}
* @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);
}
}
* @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);
}
}