X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcontroller%2Fclass_BaseController.php;h=69fa4d154669961f2f8b39156ccfea78c1bfa20b;hp=1c4d442f5aca51619ce255e8394867e3d39e1185;hb=558b417d946a1a6cee5278e86b5ed042afb3aad6;hpb=886d3459eb15f9bc6b15051b2fe2d3605c19a5d4 diff --git a/inc/classes/main/controller/class_BaseController.php b/inc/classes/main/controller/class_BaseController.php index 1c4d442f5a..69fa4d1546 100644 --- a/inc/classes/main/controller/class_BaseController.php +++ b/inc/classes/main/controller/class_BaseController.php @@ -25,14 +25,9 @@ */ class BaseController extends BaseFrameworkSystem implements Registerable { /** - * Pre filter chain instance + * Generic filter chains */ - private $preFilterChain = null; - - /** - * Post filter chain instance - */ - private $postFilterChain = null; + private $filterChains = array(); /** * Protected constructor @@ -49,13 +44,23 @@ class BaseController extends BaseFrameworkSystem implements Registerable { $this->removeSystemArray(); // Initialize both filter chains - $this->preFilterChain = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); - $this->postFilterChain = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); + $this->initFilterChain('pre'); + $this->initFilterChain('post'); // Add this controller to the registry Registry::getRegistry()->addInstance('controller', $this); } + /** + * Private method to initialize a given filter chain + * + * @param $filterChain Name of the filter chain + * @return void + */ + private function initFilterChain ($filterChain) { + $this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); + } + /** * Adds a filter to the pre filter chain * @@ -64,7 +69,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { */ public function addPreFilter (Filterable $filterInstance) { // Add the pre filter - $this->preFilterChain->addFilter($filterInstance); + $this->filterChains['pre']->addFilter($filterInstance); } /** @@ -75,7 +80,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { */ public function addPostFilter (Filterable $filterInstance) { // Add the post filter - $this->postFilterChain->addFilter($filterInstance); + $this->filterChains['post']->addFilter($filterInstance); } /** @@ -87,7 +92,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { */ protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) { // Execute all pre filters - $this->preFilterChain->processFilters($requestInstance, $responseInstance); + $this->filterChains['pre']->processFilters($requestInstance, $responseInstance); } /** @@ -99,7 +104,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { */ protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) { // Execute all post filters - $this->postFilterChain->processFilters($requestInstance, $responseInstance); + $this->filterChains['post']->processFilters($requestInstance, $responseInstance); } }