X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcontroller%2Fclass_BaseController.php;h=69fa4d154669961f2f8b39156ccfea78c1bfa20b;hp=1686f42f7c23238c475019c33017ad2df808915b;hb=abb8bf6be9f5238f8a4552707bcb190f0dbf0b7a;hpb=86553167136d11d44e1d938e964134c038785e3e diff --git a/inc/classes/main/controller/class_BaseController.php b/inc/classes/main/controller/class_BaseController.php index 1686f42..69fa4d1 100644 --- a/inc/classes/main/controller/class_BaseController.php +++ b/inc/classes/main/controller/class_BaseController.php @@ -6,7 +6,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @@ -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); } }