X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fcontroller%2Fclass_BaseController.php;h=dc5fe7045a13e3cae5ef180923a85449e54cc8ec;hb=498e6b065ce47804bff4e1073592a2cc8e28f8ef;hp=97349d5ed51709b30ad373a7ef46c342593ade04;hpb=8b7563e0de442492f93be4c24efdb902474fa86c;p=core.git diff --git a/framework/main/classes/controller/class_BaseController.php b/framework/main/classes/controller/class_BaseController.php index 97349d5e..dc5fe704 100644 --- a/framework/main/classes/controller/class_BaseController.php +++ b/framework/main/classes/controller/class_BaseController.php @@ -1,16 +1,17 @@ * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -36,7 +37,7 @@ use CoreFramework\Response\Responseable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseController extends BaseFrameworkSystem implements Registerable { +abstract class BaseController extends BaseFrameworkSystem implements Registerable { // Exception constants const EXCEPTION_FILTER_CHAIN_INVALID = 0xf10; @@ -44,10 +45,15 @@ class BaseController extends BaseFrameworkSystem implements Registerable { const FILTER_CHAIN_PRE_COMMAND = 'controller_pre_command'; const FILTER_CHAIN_POST_COMMAND = 'controller_post_command'; + /** + * Resolver instance + */ + private $resolverInstance = NULL; + /** * Generic filter chains */ - private $filterChains = array(); + private $filterChains = []; /** * Protected constructor @@ -55,7 +61,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { * @param $className Name of the class * @return void */ - protected function __construct ($className) { + protected function __construct (string $className) { // Call parent constructor parent::__construct($className); @@ -64,7 +70,26 @@ class BaseController extends BaseFrameworkSystem implements Registerable { $this->initFilterChain(self::FILTER_CHAIN_POST_COMMAND); // Add this controller to the registry - Registry::getRegistry()->addInstance('controller', $this); + GenericRegistry::getRegistry()->addInstance('controller', $this); + } + + /** + * Setter for resolver instance + * + * @param $resolverInstance Instance of a command resolver class + * @return void + */ + protected final function setResolverInstance (Resolver $resolverInstance) { + $this->resolverInstance = $resolverInstance; + } + + /** + * Getter for resolver instance + * + * @return $resolverInstance Instance of a command resolver class + */ + protected final function getResolverInstance () { + return $this->resolverInstance; } /** @@ -110,7 +135,7 @@ class BaseController extends BaseFrameworkSystem implements Registerable { $formAction = $requestInstance->getRequestElement('form'); // Get command instance from resolver - $commandInstance = $this->getResolverInstance()->resolveCommand($formAction); + $commandInstance = $this->getResolverInstance()->resolveCommand('Org\Mxchange\CoreFramework\Command\Failed', $formAction); // Add more filters by the command $commandInstance->addExtraFilters($this, $requestInstance);