*/
public final function setAppShortName (string $shortName) {
// Cast and set it
- $this->shortName = (string) $shortName;
+ $this->shortName = $shortName;
}
}
* @param $str A string (maybe) without trailing slash
* @return $str A string with an auto-appended trailing slash
*/
- public final function addMissingTrailingSlash ($str) {
+ public final function addMissingTrailingSlash (string $str) {
// Is there a trailing slash?
if (substr($str, -1, 1) != '/') {
$str .= '/';
* @param $element Element to check
* @return $isset Whether the given key is set
*/
- protected final function isGenericArrayElementSet ($keyGroup, $subGroup, $key, $element) {
+ protected final function isGenericArrayElementSet (string $keyGroup, string $subGroup, $key, $element) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
* @param $key Key to check
* @return $isset Whether the given key is set
*/
- protected final function isGenericArrayKeySet ($keyGroup, $subGroup, $key) {
+ protected final function isGenericArrayKeySet (string $keyGroup, string $subGroup, $key) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
* @param $subGroup Sub group
* @return $isset Whether the given group is set
*/
- protected final function isGenericArrayGroupSet ($keyGroup, $subGroup) {
+ protected final function isGenericArrayGroupSet (string $keyGroup, string $subGroup) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
* @param $subGroup Sub key group
* @return $array An array with all array elements
*/
- protected final function getGenericSubArray ($keyGroup, $subGroup) {
+ protected final function getGenericSubArray (string $keyGroup, string $subGroup) {
// Is it there?
if (!$this->isGenericArrayGroupSet($keyGroup, $subGroup)) {
// No, then abort here
* @param $key Key to unset
* @return void
*/
- protected final function unsetGenericArrayKey ($keyGroup, $subGroup, $key) {
+ protected final function unsetGenericArrayKey (string $keyGroup, string $subGroup, $key) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
* @param $element Element to unset
* @return void
*/
- protected final function unsetGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
+ protected final function unsetGenericArrayElement (string $keyGroup, string $subGroup, $key, $element) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
* @param $value Value to add/append
* @return void
*/
- protected final function appendStringToGenericArrayKey ($keyGroup, $subGroup, $key, $value, $appendGlue = '') {
+ protected final function appendStringToGenericArrayKey (string $keyGroup, string $subGroup, $key, string $value, $appendGlue = '') {
// Debug message
//* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true) . ',appendGlue=' . $appendGlue);
* @param $value Value to add/append
* @return void
*/
- protected final function appendStringToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') {
+ protected final function appendStringToGenericArrayElement (string $keyGroup, string $subGroup, $key, $element, $value, $appendGlue = '') {
// Debug message
//* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true) . ',appendGlue=' . $appendGlue);
* @param $value Value to add/append
* @return void
*/
- protected final function setStringGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value, $appendGlue = '') {
+ protected final function setStringGenericArrayElement (string $keyGroup, string $subGroup, $key, $element, $value, $appendGlue = '') {
// Debug message
//* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true) . ',appendGlue=' . $appendGlue);
* @param $forceInit Optionally force initialization
* @return void
*/
- protected final function initGenericArrayGroup ($keyGroup, $subGroup, $forceInit = false) {
+ protected final function initGenericArrayGroup (string $keyGroup, string $subGroup, bool $forceInit = false) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',forceInit=' . intval($forceInit));
* @param $forceInit Optionally force initialization
* @return void
*/
- protected final function initGenericArrayKey ($keyGroup, $subGroup, $key, $forceInit = false) {
+ protected final function initGenericArrayKey (string $keyGroup, string $subGroup, $key, bool $forceInit = false) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',forceInit=' . intval($forceInit));
* @param $forceInit Optionally force initialization
* @return void
*/
- protected final function initGenericArrayElement ($keyGroup, $subGroup, $key, $element, $forceInit = false) {
+ protected final function initGenericArrayElement (string $keyGroup, string $subGroup, $key, $element, bool $forceInit = false) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',forceInit=' . intval($forceInit));
* @param $value Value to add/append
* @return $count Number of array elements
*/
- protected final function pushValueToGenericArrayKey ($keyGroup, $subGroup, $key, $value) {
+ protected final function pushValueToGenericArrayKey (string $keyGroup, string $subGroup, $key, $value) {
// Debug message
//* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true));
* @param $value Value to add/append
* @return $count Number of array elements
*/
- protected final function pushValueToGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
+ protected final function pushValueToGenericArrayElement (string $keyGroup, string $subGroup, $key, $element, $value) {
// Debug message
//* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true));
* @param $key Key to unset
* @return $value Last "popped" value
*/
- protected final function popGenericArrayElement ($keyGroup, $subGroup, $key) {
+ protected final function popGenericArrayElement (string $keyGroup, string $subGroup, $key) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
* @param $key Key to unset
* @return $value Last "popped" value
*/
- protected final function shiftGenericArrayElement ($keyGroup, $subGroup, $key) {
+ protected final function shiftGenericArrayElement (string $keyGroup, string $subGroup, $key) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
* @param $subGroup Sub group for the key
* @return $count Count of given group
*/
- protected final function countGenericArrayGroup ($keyGroup, $subGroup) {
+ protected final function countGenericArrayGroup (string $keyGroup, string $subGroup) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
* @para $key Key to count
* @return $count Count of given key
*/
- protected final function countGenericArrayElements ($keyGroup, $subGroup, $key) {
+ protected final function countGenericArrayElements (string $keyGroup, string $subGroup, $key) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
* @param $value Mixed value from generic array element
* @return void
*/
- protected final function setGenericArrayKey ($keyGroup, $subGroup, $key, $value) {
+ protected final function setGenericArrayKey (string $keyGroup, string $subGroup, $key, $value) {
// Debug message
//* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',value[' . gettype($value) . ']=' . print_r($value, true));
* @param $key Key to unset
* @return $value Mixed value from generic array element
*/
- protected final function getGenericArrayKey ($keyGroup, $subGroup, $key) {
+ protected final function getGenericArrayKey (string $keyGroup, string $subGroup, $key) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
* @param $value Value to set
* @return void
*/
- protected final function setGenericArrayElement ($keyGroup, $subGroup, $key, $element, $value) {
+ protected final function setGenericArrayElement (string $keyGroup, string $subGroup, $key, $element, $value) {
// Debug message
//* NOISY-DEBUG: */ if (!is_object($value)) $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element . ',value[' . gettype($value) . ']=' . print_r($value, true));
* @param $element Element to look for
* @return $value Mixed value from generic array element
*/
- protected final function getGenericArrayElement ($keyGroup, $subGroup, $key, $element) {
+ protected final function getGenericArrayElement (string $keyGroup, string $subGroup, $key, $element) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key . ',element=' . $element);
* @param $subGroup Sub group for the key
* @return $isValid Whether given sub group is valid
*/
- protected final function isValidGenericArrayGroup ($keyGroup, $subGroup) {
+ protected final function isValidGenericArrayGroup (string $keyGroup, string $subGroup) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup);
* @param $key Key to check
* @return $isValid Whether given sub group is valid
*/
- protected final function isValidGenericArrayKey ($keyGroup, $subGroup, $key) {
+ protected final function isValidGenericArrayKey (string $keyGroup, string $subGroup, $key) {
// Debug message
//* NOISY-DEBUG: */ $this->outputLine('[' . __METHOD__ . ':' . __LINE__ . '] keyGroup=' . $keyGroup . ',subGroup=' . $subGroup . ',key=' . $key);
* @param $className Real class name
*/
public function __construct (string $className) {
- $this->realClass = (string) $className;
+ $this->realClass = $className;
}
/**
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
use Org\Mxchange\CoreFramework\Generic\FrameworkException;
-use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler;
-use Org\Mxchange\CoreFramework\Middleware\Compressor\CompressorChannel;
+use Org\Mxchange\CoreFramework\Traits\Compressor\Channel\CompressorChannelTrait;
+use Org\Mxchange\CoreFramework\Traits\Handler\Io\IoHandlerTrait;
// Import SPL stuff
use \SplFileInfo;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
+ // Load traits
+ use CompressorChannelTrait;
+ use IoHandlerTrait;
+
/**
* The file's extension
*/
*/
private $indexKey = '__idx';
- /**
- * The file I/O instance for the template loader
- */
- private $fileIoInstance = NULL;
-
- /**
- * A Compressor instance
- */
- private $compressorChannelInstance = NULL;
-
/**
* The protected constructor. Do never instance from outside! You need to
* set a local file path. The class will then validate it.
// Get an instance
$databaseInstance = new CachedLocalFileDatabase();
- // Get a new compressor channel instance
- $compressorChannelInstance = ObjectFactory::createObjectByConfiguredName('compressor_channel_class');
-
// Set the compressor channel
- $databaseInstance->setCompressorChannelInstance($compressorChannelInstance);
+ $databaseInstance->setCompressorChannelInstance(ObjectFactory::createObjectByConfiguredName('compressor_channel_class'));
- // Get a file IO handler
- $fileIoInstance = ObjectFactory::createObjectByConfiguredName('file_io_class');
-
- // ... and set it
- $databaseInstance->setFileIoInstance($fileIoInstance);
+ // Get a file IO handler and set it
+ $databaseInstance->setFileIoInstance(ObjectFactory::createObjectByConfiguredName('file_io_class'));
// "Connect" to the database
$databaseInstance->connectToDatabase();
public final function getIndexKey () {
return $this->indexKey;
}
- /**
- * Private getter for file IO instance
- *
- * @return $fileIoInstance An instance to the file I/O sub-system
- */
- protected final function getFileIoInstance () {
- return $this->fileIoInstance;
- }
-
- /**
- * Setter for file I/O instance
- *
- * @param $fileIoInstance An instance to the file I/O sub-system
- * @return void
- */
- public final function setFileIoInstance (IoHandler $fileIoInstance) {
- $this->fileIoInstance = $fileIoInstance;
- }
-
- /**
- * Setter for compressor channel
- *
- * @param $compressorChannelInstance An instance of a CompressorChannel class
- * @return void
- */
- protected final function setCompressorChannelInstance (CompressorChannel $compressorChannelInstance) {
- $this->compressorChannelInstance = $compressorChannelInstance;
- }
-
- /**
- * Getter for compressor channel
- *
- * @return $compressorChannelInstance An instance of a CompressorChannel class
- */
- protected final function getCompressorChannelInstance () {
- return $this->compressorChannelInstance;
- }
/**
* Reads a local data file and returns it's contents in an array
use Org\Mxchange\CoreFramework\Database\Backend\BaseDatabaseBackend;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
+use Org\Mxchange\CoreFramework\Traits\Cache\CacheableTrait;
/**
* A generic database frontend
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
abstract class BaseDatabaseFrontend extends BaseFrameworkSystem {
- /**
- * Cache instance
- */
- private $cacheInstance = NULL;
+ // Load traits
+ use CacheableTrait;
/**
* Current table name to use
// Is the cache enabled?
if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
// Set the new instance
- $this->cacheInstance = CacheFactory::getFactory()->createConfiguredCache();
+ $this->setCacheInstance(ObjectFactory::createObjectByConfiguredName('cache_class'));
} // END - if
}
* @param $tableName Name of table name to set
* @return void
*/
- protected final function setTableName ($tableName) {
- $this->tableName = (string) $tableName;
+ protected final function setTableName (string $tableName) {
+ $this->tableName = $tableName;
}
/**
// Does this key exists in cache?
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey));
- if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) {
+ if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->getCacheInstance()->offsetExists($cacheKey))) {
// Purge the cache
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Calling this->cacheInstance->purgeOffset(%s) ...', $cacheKey));
- $this->cacheInstance->purgeOffset($cacheKey);
+ $this->getCacheInstance()->purgeOffset($cacheKey);
} // END - if
// Handle it over to the middleware
} // END - if
// Does this key exists in cache?
- if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey))) {
+ if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->getCacheInstance()->offsetExists($cacheKey))) {
// Purge the cache
- $this->cacheInstance->purgeOffset($cacheKey);
+ $this->getCacheInstance()->purgeOffset($cacheKey);
} // END - if
// Handle it over to the middleware
// Does this key exists in cache?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: cacheKey[%s]=%s', gettype($cacheKey), $cacheKey));
- if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) {
+ if ((FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) && ($this->getCacheInstance()->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) {
// Then use this result
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Cache used for cacheKey=%s', $cacheKey));
- $result = $this->cacheInstance->offsetGet($cacheKey);
+ $result = $this->getCacheInstance()->offsetGet($cacheKey);
} else {
// Now it's time to ask the database layer for this select statement
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Quering database, cacheKey=%s ...', $cacheKey));
if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('database_cache_enabled') === true) {
// A valid result has returned from the database layer
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-WRAPPER: Setting cacheKey=%s with result()=%d entries', $cacheKey, count($result)));
- $this->cacheInstance->offsetSet($cacheKey, $result);
+ $this->getCacheInstance()->offsetSet($cacheKey, $result);
} // END - if
} else {
// This invalid result must be wrapped
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Mxchange\CoreFramework\Factory\Cache;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Mxchange\CoreFramework\Factory\BaseFactory;
-use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-
-/**
- * A cache factory
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @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
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class CacheFactory extends BaseFactory {
- /**
- * Singleton instance
- */
- private static $selfInstance = NULL;
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Singleton getter for this class
- *
- * @return $selfInstance An instance of this class
- */
- public static final function getFactory () {
- // Is the instance null?
- if (is_null(self::$selfInstance)) {
- // Set a new one
- self::$selfInstance = new CacheFactory();
- } // END - if
-
- // Return the instance
- return self::$selfInstance;
- }
-
- /**
- * Creates a configured cache instance
- *
- * @return $cacheInstance An instance of the configured cache
- */
- public function createConfiguredCache () {
- // Read the config entry
- $cacheType = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('cache_class');
-
- // And get a new instance
- $cacheInstance = ObjectFactory::createObjectByName($cacheType);
-
- // Return the instance
- return $cacheInstance;
- }
-
-}
$seekStatus = $this->seek(0, SEEK_END);
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:%d:] seekStatus=%d', __METHOD__, __LINE__, $seekStatus));
- // Get position again (which is the end of the file)
+ // Get position again (which is the end of the file)
$size = $this->determineSeekPosition();
// Reset seek position to old
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Is the form set?
- if (($requestInstance->getRequestElement('command') !== 'do_form') || (!$requestInstance->isRequestElementSet('form'))) {
+ if (($requestInstance->getRequestElement('command') !== 'do_form') || (!$requestInstance->isRequestElementSet('form'))) {
// Required field not set
$requestInstance->requestIsValid(false);
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
-use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler;
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Response\Responseable;
use Org\Mxchange\CoreFramework\Stacker\Stackable;
+use Org\Mxchange\CoreFramework\Traits\Handler\Io\IoHandlerTrait;
use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
// Import SPL stuff
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
abstract class BaseTemplateEngine extends BaseFrameworkSystem {
+ // Load traits
+ use IoHandlerTrait;
+
// Exception codes for the template engine
const EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED = 0x110;
const EXCEPTION_TEMPLATE_CONTAINS_INVALID_VAR = 0x111;
const EXCEPTION_INVALID_VIEW_HELPER = 0x112;
const EXCEPTION_VARIABLE_IS_MISSING = 0x113;
- /**
- * The file I/O instance for the template loader
- */
- private $fileIoInstance = NULL;
-
/**
* The local path name where all templates and sub folders for special
* templates are stored. We will internally determine the language plus
return $this->xmlCompacting;
}
- /**
- * Private getter for file IO instance
- *
- * @return $fileIoInstance An instance to the file I/O sub-system
- */
- protected final function getFileIoInstance () {
- return $this->fileIoInstance;
- }
-
- /**
- * Setter for file I/O instance
- *
- * @param $fileIoInstance An instance to the file I/O sub-system
- * @return void
- */
- public final function setFileIoInstance (IoHandler $fileIoInstance) {
- $this->fileIoInstance = $fileIoInstance;
- }
-
/**
* Setter for stacker instance
*
// Extract backtrace
$this->saveBackTrace();
- // Cast all data
- $message = (string) $message;
- $code = (int) $code;
-
// In emergency exit?
if (defined('EMERGENCY_EXIT_CALLED')) {
// Output message
*
* @return $indexKey Index key
*/
- function getIndexKey();
+ function getIndexKey ();
/**
* Getter for last exception
*
* @return $lastException Last exception or NULL if none occured
*/
- function getLastException();
+ function getLastException ();
/**
* Do a "select" query on the current table with the given search criteria and
* @param $onlyKeys Only use these keys for a cache key
* @return $resultInstance An instance of a database result class
*/
- function doSelectByCriteria(Criteria $criteriaInstance, array $onlyKeys = []);
+ function doSelectByCriteria (Criteria $criteriaInstance, array $onlyKeys = []);
/**
* Count the numbers of rows we shall receive
* @param $onlyKeys Only use these keys for a cache key
* @return $numRows Numbers of rows of database entries
*/
- function doSelectCountByCriteria(Criteria $criteriaInstance, array $onlyKeys = []);
+ function doSelectCountByCriteria (Criteria $criteriaInstance, array $onlyKeys = []);
/**
* Getter for primary key used in wrapped table
*
* @return $primaryKey Primary key used in wrapped table
*/
- function getPrimaryKeyValue();
+ function getPrimaryKeyValue ();
/**
* Counts total rows of this table
*
* @return $count Total rows of this table
*/
- function countTotalRows();
+ function countTotalRows ();
}
* @param $host Hostname to use
* @return void
*/
- function setConnectionData ($login, $pass, $dbase, $host='localhost');
+ function setConnectionData (string $login, string $pass, string $dbase, string $host = 'localhost');
/**
* Getter for connection data
* @param $criteriaInstance An instance of a Criteria class
* @return $result The result as an array
*/
- function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance);
+ function doSelectByTableCriteria (string $tableName, Criteria $criteriaInstance);
/**
* Getter for last exception
* @param $tableName Name of table we need the primary key column from
* @return $primaryKey Primary key column of requested table
*/
- function getPrimaryKeyOfTable ($tableName);
+ function getPrimaryKeyOfTable (string $tableName);
/**
* Removes non-public data from given array.
* @param $tableName Table name
* @return $count Total rows of given table
*/
- function countTotalRows($tableName);
+ function countTotalRows (string $tableName);
}
* @param $host Host to connect to (default: 127.0.0.1)
* @return void
*/
- public final function setConnectionData ($login, $pass, $dbase, $host = '127.0.0.1') {
+ public final function setConnectionData (string $login, string $pass, string $dbase, string $host = '127.0.0.1') {
// Transfer connection data
- $this->connectData['login'] = (string) $login;
- $this->connectData['pass'] = (string) $pass;
- $this->connectData['dbase'] = (string) $dbase;
- $this->connectData['host'] = (string) $host;
+ $this->connectData['login'] = $login;
+ $this->connectData['pass'] = $pass;
+ $this->connectData['dbase'] = $dbase;
+ $this->connectData['host'] = $host;
}
/**
* @param $criteriaInstance An instance of a Criteria class
* @return $result The result as an array
*/
- public function doSelectByTableCriteria ($tableName, Criteria $criteriaInstance) {
+ public function doSelectByTableCriteria (string $tableName, Criteria $criteriaInstance) {
// Connect to the database
$this->dbLayer->connectToDatabase();
* @param $tableName Name of table we need the primary key column from
* @return $primaryKey Primary key column of requested table
*/
- public function getPrimaryKeyOfTable ($tableName) {
+ public function getPrimaryKeyOfTable (string $tableName) {
// Connect to the database
$this->dbLayer->connectToDatabase();
* @param $tableName Table name
* @return $count Total row count
*/
- public function countTotalRows ($tableName) {
+ public function countTotalRows (string $tableName) {
// Connect to the database
$this->dbLayer->connectToDatabase();
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Cache;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Cache\Cacheable;
+
+/**
+ * A trait for cache
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait CacheableTrait {
+ /**
+ * Cache instance
+ */
+ private $cacheInstance = NULL;
+
+ /**
+ * Setter for table name
+ *
+ * @param $cacheInstance Name of table name to set
+ * @return void
+ */
+ protected final function setCacheInstance (Cacheable $cacheInstance) {
+ $this->cacheInstance = $cacheInstance;
+ }
+
+ /**
+ * Getter for table name
+ *
+ * @return $cacheInstance Name of table name to set
+ */
+ protected final function getCacheInstance () {
+ return $this->cacheInstance;
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Compressor\Channel;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Middleware\Compressor\CompressorChannel;
+
+/**
+ * A trait for compressor channels
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait CompressorChannelTrait {
+ /**
+ * A Compressor instance
+ */
+ private $compressorChannelInstance = NULL;
+
+ /**
+ * Setter for compressor channel
+ *
+ * @param $compressorChannelInstance An instance of a CompressorChannel class
+ * @return void
+ */
+ protected final function setCompressorChannelInstance (CompressorChannel $compressorChannelInstance) {
+ $this->compressorChannelInstance = $compressorChannelInstance;
+ }
+
+ /**
+ * Getter for compressor channel
+ *
+ * @return $compressorChannelInstance An instance of a CompressorChannel class
+ */
+ protected final function getCompressorChannelInstance () {
+ return $this->compressorChannelInstance;
+ }
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Handler\Io;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler;
+
+/**
+ * A trait for file I/O handler
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+trait IoHandlerTrait {
+ /**
+ * The file I/O instance for the template loader
+ */
+ private $fileIoInstance = NULL;
+
+ /**
+ * Private getter for file IO instance
+ *
+ * @return $fileIoInstance An instance to the file I/O sub-system
+ */
+ protected final function getFileIoInstance () {
+ return $this->fileIoInstance;
+ }
+
+ /**
+ * Setter for file I/O instance
+ *
+ * @param $fileIoInstance An instance to the file I/O sub-system
+ * @return void
+ */
+ public final function setFileIoInstance (IoHandler $fileIoInstance) {
+ $this->fileIoInstance = $fileIoInstance;
+ }
+
+}