// Import framework stuff
use Org\Mxchange\CoreFramework\Chain\Filter\InvalidFilterChainException;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
use Org\Mxchange\CoreFramework\Filter\Filterable;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Registry\Registerable;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Response\Responseable;
+use Org\Mxchange\CoreFramework\Traits\Resolver\ResolverTrait;
/**
* A generic controller class. You should extend this base class if you want to
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
abstract class BaseController extends BaseFrameworkSystem implements Registerable {
+ // Load traits
+ use ResolverTrait;
+
// Exception constants
const EXCEPTION_FILTER_CHAIN_INVALID = 0xf10;
/**
* Generic filter chains
*/
- private $filterChains = array();
+ private $filterChains = [];
/**
* Protected constructor
* @param $className Name of the class
* @return void
*/
- protected function __construct ($className) {
+ protected function __construct (string $className) {
// Call parent constructor
parent::__construct($className);
$this->executePreFilters($requestInstance, $responseInstance);
// This request was valid! :-D
- $requestInstance->requestIsValid();
+ $requestInstance->setIsRequestValid(TRUE);
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
// Execute *very* generic post filters
$this->executePostFilters($requestInstance, $responseInstance);
- } // END - if
+ }
// Flush the buffer out
$responseInstance->flushBuffer();
}
// This request was valid! :-D
- $requestInstance->requestIsValid();
+ $requestInstance->setIsRequestValid(TRUE);
// Execute the command
$commandInstance->execute($requestInstance, $responseInstance);
* @param $filterChain Name of the filter chain
* @return void
*/
- protected function initFilterChain ($filterChain) {
+ protected function initFilterChain (string $filterChain) {
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: START');
$this->filterChains[$filterChain] = ObjectFactory::createObjectByConfiguredName('filter_chain_class');
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ' init: FINISHED');
* @return void
* @throws InvalidFilterChainException If the filter chain is invalid
*/
- protected function addFilter ($filterChain, Filterable $filterInstance) {
+ protected function addFilter (string $filterChain, Filterable $filterInstance) {
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONTROLLER: ' . $filterChain . ',' . $filterInstance->__toString(). ' add: START');
// Test if the filter is there
if (!isset($this->filterChains[$filterChain])) {
// Throw an exception here
throw new InvalidFilterChainException(array($this, $filterChain), self::EXCEPTION_FILTER_CHAIN_INVALID);
- } // END - if
+ }
// Add the filter
$this->filterChains[$filterChain]->addFilter($filterInstance);
* @return void
* @throws InvalidFilterChainException If the filter chain is invalid
*/
- protected function executeFilters ($filterChain, Requestable $requestInstance, Responseable $responseInstance) {
+ protected function executeFilters (string $filterChain, Requestable $requestInstance, Responseable $responseInstance) {
// Test if the filter is there
if (!isset($this->filterChains[$filterChain])) {
// Throw an exception here
throw new InvalidFilterChainException(array($this, $filterChain), self::EXCEPTION_FILTER_CHAIN_INVALID);
- } // END - if
+ }
// Run all filters
$this->filterChains[$filterChain]->processFilters($requestInstance, $responseInstance);