+ $this->removeSystemArray();
+
+ // Initialize both filter chains
+ $this->preFilterChain = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
+ $this->postFilterChain = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
+
+ // Add this controller to the registry
+ Registry::getRegistry()->addInstance('controller', $this);
+ }
+
+ /**
+ * 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) {
+ // Execute all pre filters
+ $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) {
+ // Execute all post filters
+ $this->postFilterChain->processFilters($requestInstance, $responseInstance);