X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcontroller%2Fclass_BaseController.php;h=69fa4d154669961f2f8b39156ccfea78c1bfa20b;hb=12dbc1af8f0bc2981711b17c7c955f270c440b35;hp=a2bf81158444abaea1aef399342006ba2683eee4;hpb=12a993738a1d1bea29a886e06478beb145c275e5;p=hub.git diff --git a/inc/classes/main/controller/class_BaseController.php b/inc/classes/main/controller/class_BaseController.php index a2bf81158..69fa4d154 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 * @@ -23,57 +23,42 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseController extends BaseFrameworkSystem { +class BaseController extends BaseFrameworkSystem implements Registerable { /** - * Instance of a CommandResolver class + * Generic filter chains */ - private $resolverInstance = null; - - /** - * Pre filter chain instance - */ - private $preFilterChain = null; - - /** - * Post filter chain instance - */ - private $postFilterChain = null; + private $filterChains = array(); /** * Protected constructor * + * @param $className Name of the class * @return void */ - protected function __construct ($class) { + protected function __construct ($className) { // Call parent constructor - parent::__construct($class); + parent::__construct($className); // Clean up a little $this->removeNumberFormaters(); $this->removeSystemArray(); // Initialize both filter chains - $this->preFilterChain = FilterChain::createFilterChain(); - $this->postFilterChain = FilterChain::createFilterChain(); - } + $this->initFilterChain('pre'); + $this->initFilterChain('post'); - /** - * Getter for a command resolver instance - * - * @return $resolverInstance An instance of a command resolver class - */ - public final function getResolverInstance () { - return $this->resolverInstance; + // Add this controller to the registry + Registry::getRegistry()->addInstance('controller', $this); } /** - * Setter for a command resolver instance + * Private method to initialize a given filter chain * - * @param $resolverInstance An instance of a command resolver class + * @param $filterChain Name of the filter chain * @return void */ - public final function setResolverInstance (CommandResolver $resolverInstance) { - $this->resolverInstance = $resolverInstance; + private function initFilterChain ($filterChain) { + $this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class'); } /** @@ -84,7 +69,7 @@ class BaseController extends BaseFrameworkSystem { */ public function addPreFilter (Filterable $filterInstance) { // Add the pre filter - $this->preFilterChain->addFilter($filterInstance); + $this->filterChains['pre']->addFilter($filterInstance); } /** @@ -95,7 +80,7 @@ class BaseController extends BaseFrameworkSystem { */ public function addPostFilter (Filterable $filterInstance) { // Add the post filter - $this->postFilterChain->addFilter($filterInstance); + $this->filterChains['post']->addFilter($filterInstance); } /** @@ -107,7 +92,7 @@ class BaseController extends BaseFrameworkSystem { */ protected function executePreFilters (Requestable $requestInstance, Responseable $responseInstance) { // Execute all pre filters - $this->preFilterChain->processFilters($requestInstance, $responseInstance); + $this->filterChains['pre']->processFilters($requestInstance, $responseInstance); } /** @@ -119,7 +104,7 @@ class BaseController extends BaseFrameworkSystem { */ protected function executePostFilters (Requestable $requestInstance, Responseable $responseInstance) { // Execute all post filters - $this->postFilterChain->processFilters($requestInstance, $responseInstance); + $this->filterChains['post']->processFilters($requestInstance, $responseInstance); } }