* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class BaseController extends BaseFrameworkSystem {
+ /**
+ * Instance of a CommandResolver class
+ */
+ private $resolverInstance = null;
+
+ /**
+ * Pre filter chain instance
+ */
+ private $preFilterChain = null;
+
+ /**
+ * Post filter chain instance
+ */
+ private $postFilterChain = null;
+
/**
* Protected constructor
*
// Clean up a little
$this->removeNumberFormaters();
+ $this->removeSystemArray();
+
+ // Initialize both filter chains
+ $this->preFilterChain = FilterChain::createFilterChain();
+ $this->postFilterChain = FilterChain::createFilterChain();
+ }
+
+ /**
+ * Getter for a command resolver instance
+ *
+ * @
+ * @return $resolverInstance An instance of a command resolver class
+ */
+ public final function getResolverInstance () {
+ return $this->resolverInstance;
+ }
+
+ /**
+ * Setter for a command resolver instance
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return void
+ */
+ public final function setResolverInstance (CommandResolver $resolverInstance) {
+ $this->resolverInstance = $resolverInstance;
+ }
+
+ /**
+ * Adds a filter to the pre filter chain
+ *
+ * @param $filterInstance An instance of a filter
+ * @return void
+ */
+ public function addPreFilter (Filterable $filterInstance) {
+ // Add the pre filter
+ $this->preFilterChain->addFilter($filterInstance);
+ }
+
+ /**
+ * Adds a filter to the post filter chain
+ *
+ * @param $filterInstance An instance of a filter
+ * @return void
+ */
+ public function addPostFilter (Filterable $filterInstance) {
+ // Add the post filter
+ $this->postFilterChain->addFilter($filterInstance);
+ }
+
+ /**
+ * Executes all pre filters
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->preFilterChain->processFilters($requestInstance, $responseInstance);
+ }
+
+ /**
+ * Executes all post filters
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->postFilterChain->processFilters($requestInstance, $responseInstance);
}
}