From fcf4d2298dd734a93fe99aede7d374e80d39f9ec Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 2 Dec 2020 00:36:50 +0100 Subject: [PATCH] Continued: - Removed monolithic BaseFrameworkSystem->flushPendingUpdates() - REFACTURING: moved some instances to traits, will continue with other instances after these have been tested MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- framework/loader/class_ClassLoader.php | 9 +- .../classes/class_BaseFrameworkSystem.php | 102 +----------------- .../payment/class_LocalPaymentDiscovery.php | 4 + .../class_UserStatusConfimedUpdateFilter.php | 1 + .../filter/update/class_UserUpdateFilter.php | 1 + .../main/classes/points/class_UserPoints.php | 6 ++ .../reader/class_ConsoleNewsReader.php | 4 + .../reader/class_DefaultNewsReader.php | 4 + .../main/classes/user/class_BaseUser.php | 4 + .../main/classes/user/guest/class_Guest.php | 12 +-- .../main/classes/user/member/class_Member.php | 3 +- .../io/file/handler/class_IoHandler.php | 14 +-- .../main/middleware/class_BaseMiddleware.php | 27 +---- .../middleware/io/class_FileIoHandler.php | 63 ++--------- .../main/traits/crypto/class_CryptoTrait.php | 55 ++++++++++ .../account/class_ManageableAccountTrait.php | 56 ++++++++++ .../search/class_SearchableResultTrait.php | 56 ++++++++++ .../input/class_FileInputStreamerTrait.php | 55 ++++++++++ .../output/class_FileOutputStreamerTrait.php | 55 ++++++++++ .../output/class_OutputStreamerTrait.php | 55 ++++++++++ 20 files changed, 384 insertions(+), 202 deletions(-) create mode 100644 framework/main/traits/crypto/class_CryptoTrait.php create mode 100644 framework/main/traits/manager/account/class_ManageableAccountTrait.php create mode 100644 framework/main/traits/result/search/class_SearchableResultTrait.php create mode 100644 framework/main/traits/streamer/file/input/class_FileInputStreamerTrait.php create mode 100644 framework/main/traits/streamer/file/output/class_FileOutputStreamerTrait.php create mode 100644 framework/main/traits/streamer/output/class_OutputStreamerTrait.php diff --git a/framework/loader/class_ClassLoader.php b/framework/loader/class_ClassLoader.php index 9e0e4bac..194e89f1 100644 --- a/framework/loader/class_ClassLoader.php +++ b/framework/loader/class_ClassLoader.php @@ -123,12 +123,13 @@ class ClassLoader { /** * Framework/application paths for classes, etc. */ - private static $frameworkPaths = array( + private static $frameworkPaths = [ + 'classes', // Classes 'exceptions', // Exceptions 'interfaces', // Interfaces - 'classes', // Classes - 'middleware' // The middleware - ); + 'middleware', // The middleware + 'traits', // Traits + ]; /** * Registered paths where test classes can be found. These are all relative diff --git a/framework/main/classes/class_BaseFrameworkSystem.php b/framework/main/classes/class_BaseFrameworkSystem.php index 7c0ed665..7195861e 100644 --- a/framework/main/classes/class_BaseFrameworkSystem.php +++ b/framework/main/classes/class_BaseFrameworkSystem.php @@ -5,7 +5,6 @@ namespace Org\Mxchange\CoreFramework\Object; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; use Org\Mxchange\CoreFramework\Criteria\Criteria; -use Org\Mxchange\CoreFramework\Crypto\Cryptable; use Org\Mxchange\CoreFramework\Database\Frontend\DatabaseWrapper; use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint; use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory; @@ -19,12 +18,10 @@ use Org\Mxchange\CoreFramework\Manager\ManageableApplication; use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware; use Org\Mxchange\CoreFramework\Registry\GenericRegistry; use Org\Mxchange\CoreFramework\Result\Database\CachedDatabaseResult; -use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; use Org\Mxchange\CoreFramework\State\Stateable; use Org\Mxchange\CoreFramework\Stream\Input\InputStream; use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer; use Org\Mxchange\CoreFramework\Stream\Output\OutputStream; -use Org\Mxchange\CoreFramework\User\ManageableAccount; use Org\Mxchange\CoreFramework\Utils\String\StringUtils; // Import SPL stuff @@ -73,21 +70,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac */ private $realClass = __CLASS__; - /** - * Database result instance - */ - private $resultInstance = NULL; - - /** - * Instance for user class - */ - private $userInstance = NULL; - - /** - * Instance of a crypto helper - */ - private $cryptoInstance = NULL; - /** * Instance of an Iterator class */ @@ -220,9 +202,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac * @return void */ public function __destruct () { - // Flush any updated entries to the database - $this->flushPendingUpdates(); - // Is this object already destroyed? if ($this->__toString() != 'DestructedObject') { // Destroy all informations about this class but keep some text about it alive @@ -434,26 +413,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac $this->realClass = $realClass; } - /** - * Setter for database result instance - * - * @param $resultInstance An instance of a database result class - * @return void - * @todo SearchableResult and UpdateableResult shall have a super interface to use here - */ - protected final function setResultInstance (SearchableResult $resultInstance) { - $this->resultInstance = $resultInstance; - } - - /** - * Getter for database result instance - * - * @return $resultInstance An instance of a database result class - */ - public final function getResultInstance () { - return $this->resultInstance; - } - /** * Setter for debug instance * @@ -497,44 +456,6 @@ abstract class BaseFrameworkSystem extends stdClass implements FrameworkInterfac return $webOutputInstance; } - /** - * Protected setter for user instance - * - * @param $userInstance An instance of a user class - * @return void - */ - protected final function setUserInstance (ManageableAccount $userInstance) { - $this->userInstance = $userInstance; - } - - /** - * Getter for user instance - * - * @return $userInstance An instance of a user class - */ - public final function getUserInstance () { - return $this->userInstance; - } - - /** - * Setter for Cryptable instance - * - * @param $cryptoInstance An instance of a Cryptable class - * @return void - */ - protected final function setCryptoInstance (Cryptable $cryptoInstance) { - $this->cryptoInstance = $cryptoInstance; - } - - /** - * Getter for Cryptable instance - * - * @return $cryptoInstance An instance of a Cryptable class - */ - public final function getCryptoInstance () { - return $this->cryptoInstance; - } - /** * Setter for DatabaseWrapper instance * @@ -974,6 +895,7 @@ Loaded includes: * @return $entry An array with database entries * @throws NullPointerException If the database result is not found * @throws InvalidDatabaseResultException If the database result is invalid + * @todo Monolithic method, should be moved to proper classes */ protected final function getDatabaseEntry () { // Is there an instance? @@ -1075,28 +997,6 @@ Loaded includes: return $isSet; } - /** - * Flushs all pending updates to the database layer - * - * @return void - */ - public function flushPendingUpdates () { - // Get result instance - $resultInstance = $this->getResultInstance(); - - // Do we have data to update? - if ((is_object($resultInstance)) && ($resultInstance->ifDataNeedsFlush())) { - // Get wrapper class name config entry - $configEntry = $resultInstance->getUpdateInstance()->getWrapperConfigEntry(); - - // Create object instance - $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName($configEntry); - - // Yes, then send the whole result to the database layer - $wrapperInstance->doUpdateByResult($this->getResultInstance()); - } - } - /** * Outputs a deprecation warning to the developer. * diff --git a/framework/main/classes/discovery/payment/class_LocalPaymentDiscovery.php b/framework/main/classes/discovery/payment/class_LocalPaymentDiscovery.php index 74e05ab2..aaab6c22 100644 --- a/framework/main/classes/discovery/payment/class_LocalPaymentDiscovery.php +++ b/framework/main/classes/discovery/payment/class_LocalPaymentDiscovery.php @@ -11,6 +11,7 @@ use Org\Mxchange\CoreFramework\Filter\Filterable; use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Request\Requestable; +use Org\Mxchange\CoreFramework\Traits\Result\Search\SearchableResultTrait; /** * A local payment discovery class. This class looks in local database for @@ -37,6 +38,9 @@ use Org\Mxchange\CoreFramework\Request\Requestable; * along with this program. If not, see . */ class LocalPaymentDiscovery extends BaseDiscovery implements Discoverable, Registerable { + // Load traits + use SearchableResultTrait; + /** * Protected constructor * diff --git a/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php b/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php index 8eb0cb60..1c41d370 100644 --- a/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php +++ b/framework/main/classes/filter/update/class_UserStatusConfimedUpdateFilter.php @@ -78,6 +78,7 @@ class UserStatusConfimedUpdateFilter extends BaseFilter implements Filterable { $userInstance->updateDatabaseField(UserDatabaseWrapper::DB_COLUMN_CONFIRM_HASH, ''); // Write all updates to the database + die(__METHOD__ . ': REWRITE!' . PHP_EOL); $userInstance->flushPendingUpdates(); } diff --git a/framework/main/classes/filter/update/class_UserUpdateFilter.php b/framework/main/classes/filter/update/class_UserUpdateFilter.php index f0238dd6..fd9d656c 100644 --- a/framework/main/classes/filter/update/class_UserUpdateFilter.php +++ b/framework/main/classes/filter/update/class_UserUpdateFilter.php @@ -76,6 +76,7 @@ class UserUpdateFilter extends BaseFilter implements Filterable { $authInstance->updateAuthData(); // Write all updates to the database + die(__METHOD__ . ': REWRITE!' . PHP_EOL); $userInstance->flushPendingUpdates(); } diff --git a/framework/main/classes/points/class_UserPoints.php b/framework/main/classes/points/class_UserPoints.php index b07858db..e26856ad 100644 --- a/framework/main/classes/points/class_UserPoints.php +++ b/framework/main/classes/points/class_UserPoints.php @@ -9,6 +9,8 @@ use Org\Mxchange\CoreFramework\Factory\Database\Wrapper\DatabaseWrapperFactory; use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\Registerable; +use Org\Mxchange\CoreFramework\Traits\Manager\Account\ManageableAccountTrait; +use Org\Mxchange\CoreFramework\Traits\Result\Search\SearchableResultTrait; use Org\Mxchange\CoreFramework\User\ManageableAccount; /** @@ -34,6 +36,10 @@ use Org\Mxchange\CoreFramework\User\ManageableAccount; * along with this program. If not, see . */ class UserPoints extends BaseFrameworkSystem implements Registerable, BookablePoints { + // Load traits + use ManageableAccountTrait; + use SearchableResultTrait; + /** * Amount of points */ diff --git a/framework/main/classes/reader/class_ConsoleNewsReader.php b/framework/main/classes/reader/class_ConsoleNewsReader.php index 0d1dbb97..0f19c0ae 100644 --- a/framework/main/classes/reader/class_ConsoleNewsReader.php +++ b/framework/main/classes/reader/class_ConsoleNewsReader.php @@ -10,6 +10,7 @@ use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Reader\News\ReadableNews; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Request\Requestable; +use Org\Mxchange\CoreFramework\Traits\Result\Search\SearchableResultTrait; /** * A console news reader class reads news from database layer @@ -34,6 +35,9 @@ use Org\Mxchange\CoreFramework\Request\Requestable; * along with this program. If not, see . */ class ConsoleNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable { + // Load traits + use SearchableResultTrait; + /** * Protected constructor * diff --git a/framework/main/classes/reader/class_DefaultNewsReader.php b/framework/main/classes/reader/class_DefaultNewsReader.php index ce0fd6f5..8d67d32e 100644 --- a/framework/main/classes/reader/class_DefaultNewsReader.php +++ b/framework/main/classes/reader/class_DefaultNewsReader.php @@ -9,6 +9,7 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Registry\Registerable; use Org\Mxchange\CoreFramework\Request\Requestable; +use Org\Mxchange\CoreFramework\Traits\Result\Search\SearchableResultTrait; /** * A default news reader class reads news from database layer @@ -33,6 +34,9 @@ use Org\Mxchange\CoreFramework\Request\Requestable; * along with this program. If not, see . */ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable { + // Load traits + use SearchableResultTrait; + /** * Protected constructor * diff --git a/framework/main/classes/user/class_BaseUser.php b/framework/main/classes/user/class_BaseUser.php index 36791ab5..f3da469e 100644 --- a/framework/main/classes/user/class_BaseUser.php +++ b/framework/main/classes/user/class_BaseUser.php @@ -10,6 +10,7 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; use Org\Mxchange\CoreFramework\Request\Requestable; use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; +use Org\Mxchange\CoreFramework\Traits\Result\Search\SearchableResultTrait; /** * A general user class @@ -34,6 +35,9 @@ use Org\Mxchange\CoreFramework\Result\Search\SearchableResult; * along with this program. If not, see . */ abstract class BaseUser extends BaseFrameworkSystem implements Updateable { + // Load traits + use SearchableResultTrait; + // Exception constances const EXCEPTION_USERNAME_NOT_FOUND = 0x150; const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151; diff --git a/framework/main/classes/user/guest/class_Guest.php b/framework/main/classes/user/guest/class_Guest.php index c7fb4b22..2116e5b0 100644 --- a/framework/main/classes/user/guest/class_Guest.php +++ b/framework/main/classes/user/guest/class_Guest.php @@ -124,8 +124,7 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { /** * Updates the last activity timestamp and last performed action in the - * database result. You should call flushPendingUpdates() to flush these updates - * to the database layer. + * database result. * * @param $requestInstance A requestable class instance * @return void @@ -134,13 +133,4 @@ class Guest extends BaseUser implements ManageableGuest, Registerable { // No activity will be logged for guest accounts } - /** - * Flushs all pending updates to the database layer - * - * @return void - */ - public function flushPendingUpdates () { - // No updates will be flushed to database! - } - } diff --git a/framework/main/classes/user/member/class_Member.php b/framework/main/classes/user/member/class_Member.php index 64b7cbbf..07449e68 100644 --- a/framework/main/classes/user/member/class_Member.php +++ b/framework/main/classes/user/member/class_Member.php @@ -120,8 +120,7 @@ class Member extends BaseUser implements ManageableMember, Registerable { /** * Updates the last activity timestamp and last performed action in the - * database result. You should call flushPendingUpdates() to flush these updates - * to the database layer. + * database result. * * @param $requestInstance A requestable class instance * @return void diff --git a/framework/main/interfaces/io/file/handler/class_IoHandler.php b/framework/main/interfaces/io/file/handler/class_IoHandler.php index a936a250..cf3f4adb 100644 --- a/framework/main/interfaces/io/file/handler/class_IoHandler.php +++ b/framework/main/interfaces/io/file/handler/class_IoHandler.php @@ -36,32 +36,32 @@ interface IoHandler extends FileInputStreamer, FileOutputStreamer { /** * Setter for the *real* file input instance * - * @param $inputStream The *real* file-input class + * @param $inputStreamerInstance The *real* file-input class * @return void */ - function setInputStream (FileInputStreamer $inputStream); + function setInputStreamerInstance (FileInputStreamer $inputStreamerInstance); /** * Getter for the *real* file input instance * * @return $inputStream The *real* file-input class */ - function getInputStream (); + function getInputStreamerInstance (); /** * Setter for the *real* file output instance * - * @param $outputStream The *real* file-output class + * @param $outputStreamerInstance The *real* file-output class * @return void */ - function setOutputStream (FileOutputStreamer $outputStream); + function setOutputStreamerInstance (FileOutputStreamer $outputStreamerInstance); /** * Getter for the *real* file output instance * * @return $outputStream The *real* file-output class */ - function getOutputStream (); + function getOutputStreamerInstance (); /** * Saves a file with data by using the current output stream @@ -71,6 +71,6 @@ interface IoHandler extends FileInputStreamer, FileOutputStreamer { * @param $objectInstance An instance of a FrameworkInterface class (default: NULL) * @return void */ - function saveStreamToFile (SplFileInfo $infoInstance, $dataStream, FrameworkInterface $objectInstance = NULL); + function saveStreamToFile (SplFileInfo $infoInstance, string $dataStream, FrameworkInterface $objectInstance = NULL); } diff --git a/framework/main/middleware/class_BaseMiddleware.php b/framework/main/middleware/class_BaseMiddleware.php index 257bb3fa..f2cc311b 100644 --- a/framework/main/middleware/class_BaseMiddleware.php +++ b/framework/main/middleware/class_BaseMiddleware.php @@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\Middleware; // Import framework stuff use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; -use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer; +use Org\Mxchange\CoreFramework\Traits\Streamer\Output\OutputStreamerTrait; /** * An abstract middleware class for all other middlware classes @@ -29,10 +29,8 @@ use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer; * along with this program. If not, see . */ abstract class BaseMiddleware extends BaseFrameworkSystem { - /** - * The concrete output instance - */ - private $outputInstance = NULL; + // Load traits + use OutputStreamerTrait; /** * Protected constructor @@ -45,23 +43,4 @@ abstract class BaseMiddleware extends BaseFrameworkSystem { parent::__construct($className); } - /** - * Setter for output instance - * - * @param $outputInstance The debug output instance - * @return void - */ - protected final function setOutputInstance (OutputStreamer $outputInstance) { - $this->outputInstance = $outputInstance; - } - - /** - * Getter for output instance - * - * @return $outputInstance The debug output instance - */ - protected final function getOutputInstance () { - return $this->outputInstance; - } - } diff --git a/framework/main/middleware/io/class_FileIoHandler.php b/framework/main/middleware/io/class_FileIoHandler.php index 019411e3..d145b3bb 100644 --- a/framework/main/middleware/io/class_FileIoHandler.php +++ b/framework/main/middleware/io/class_FileIoHandler.php @@ -8,8 +8,8 @@ use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException; use Org\Mxchange\CoreFramework\Handler\Stream\IoHandler; use Org\Mxchange\CoreFramework\Middleware\BaseMiddleware; -use Org\Mxchange\CoreFramework\Stream\Filesystem\FileInputStreamer; -use Org\Mxchange\CoreFramework\Stream\Filesystem\FileOutputStreamer; +use Org\Mxchange\CoreFramework\Traits\Streamer\File\Input\FileInputStreamerTrait; +use Org\Mxchange\CoreFramework\Traits\Streamer\File\Output\FileOutputStreamerTrait; // Import SPL stuff use \SplFileInfo; @@ -38,15 +38,9 @@ use \SplFileInfo; * along with this program. If not, see . */ class FileIoHandler extends BaseMiddleware implements IoHandler { - /** - * The *real* file input class we shall use for reading data - */ - private $inputStream = NULL; - - /** - * The *real* file output class we shall use for reading data - */ - private $outputStream = NULL; + // Load traits + use FileInputStreamerTrait; + use FileOutputStreamerTrait; /** * An instance of this class @@ -77,8 +71,8 @@ class FileIoHandler extends BaseMiddleware implements IoHandler { $ioHandler = new FileIoHandler(); // Set the *real* file IO instances (both the same) - $ioHandler->setInputStream(ObjectFactory::createObjectByConfiguredName('file_input_class')); - $ioHandler->setOutputStream(ObjectFactory::createObjectByConfiguredName('file_output_class')); + $ioHandler->setInputStreamerInstance(ObjectFactory::createObjectByConfiguredName('file_input_class')); + $ioHandler->setOutputStreamerInstance(ObjectFactory::createObjectByConfiguredName('file_output_class')); // Return instance return $ioHandler; @@ -93,43 +87,6 @@ class FileIoHandler extends BaseMiddleware implements IoHandler { return self::$selfInstance; } - /** - * Setter for the *real* file input instance - * - * @param $inputStream The *real* file-input class - * @return void - */ - public final function setInputStream (FileInputStreamer $inputStream) { - $this->inputStream = $inputStream; - } - - /** - * Getter for the *real* file input instance - * - * @return $inputStream The *real* file-input class - */ - public final function getInputStream () { - return $this->inputStream; - } - - /** - * Setter for the *real* file output instance - * - * @param $outputStream The *real* file-output class - * @return void - */ - public final function setOutputStream (FileOutputStreamer $outputStream) { - $this->outputStream = $outputStream; - } - - /** - * Getter for the *real* file output instance - * - * @return $outputStream The *real* file-output class - */ - public final function getOutputStream () { - return $this->outputStream; - } /** * Saves streamed (that are mostly serialized objects) data to files or * external servers. @@ -152,7 +109,7 @@ class FileIoHandler extends BaseMiddleware implements IoHandler { * @param $objectInstance An instance of a FrameworkInterface class (default: NULL) * @return void */ - public function saveStreamToFile (SplFileInfo $infoInstance, $dataStream, FrameworkInterface $objectInstance = NULL) { + public function saveStreamToFile (SplFileInfo $infoInstance, string $dataStream, FrameworkInterface $objectInstance = NULL) { // Default is this array $className = $this->__toString(); @@ -169,7 +126,7 @@ class FileIoHandler extends BaseMiddleware implements IoHandler { ); // Send the infoInstance and dataArray to the output handler - $this->getOutputStream()->saveFile($infoInstance, $dataArray); + $this->getOutputStreamerInstance()->saveFile($infoInstance, $dataArray); } /** Loads data from a file over the input handler @@ -179,7 +136,7 @@ class FileIoHandler extends BaseMiddleware implements IoHandler { */ public function loadFileContents (SplFileInfo $infoInstance) { // Read from the input handler - return $this->getInputStream()->loadFileContents($infoInstance); + return $this->getInputStreamerInstance()->loadFileContents($infoInstance); } /** diff --git a/framework/main/traits/crypto/class_CryptoTrait.php b/framework/main/traits/crypto/class_CryptoTrait.php new file mode 100644 index 00000000..1629c954 --- /dev/null +++ b/framework/main/traits/crypto/class_CryptoTrait.php @@ -0,0 +1,55 @@ + + * @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 . + */ +trait CryptoTrait { + /** + * Instance of a crypto helper + */ + private $cryptoInstance = NULL; + + /** + * Setter for Cryptable instance + * + * @param $cryptoInstance An instance of a Cryptable class + * @return void + */ + protected final function setCryptoInstance (Cryptable $cryptoInstance) { + $this->cryptoInstance = $cryptoInstance; + } + + /** + * Getter for Cryptable instance + * + * @return $cryptoInstance An instance of a Cryptable class + */ + public final function getCryptoInstance () { + return $this->cryptoInstance; + } + +} diff --git a/framework/main/traits/manager/account/class_ManageableAccountTrait.php b/framework/main/traits/manager/account/class_ManageableAccountTrait.php new file mode 100644 index 00000000..96b067dd --- /dev/null +++ b/framework/main/traits/manager/account/class_ManageableAccountTrait.php @@ -0,0 +1,56 @@ + + * @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 . + */ +trait ManageableAccountTrait { + /** + * Instance for user class + * @todo Rename to $accountInstance ? + */ + private $userInstance = NULL; + + /** + * Protected setter for user instance + * + * @param $userInstance An instance of a user class + * @return void + */ + protected final function setUserInstance (ManageableAccount $userInstance) { + $this->userInstance = $userInstance; + } + + /** + * Getter for user instance + * + * @return $userInstance An instance of a user class + */ + public final function getUserInstance () { + return $this->userInstance; + } + +} diff --git a/framework/main/traits/result/search/class_SearchableResultTrait.php b/framework/main/traits/result/search/class_SearchableResultTrait.php new file mode 100644 index 00000000..59effe2a --- /dev/null +++ b/framework/main/traits/result/search/class_SearchableResultTrait.php @@ -0,0 +1,56 @@ + + * @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 . + */ +trait SearchableResultTrait { + /** + * Database result instance + */ + private $resultInstance = NULL; + + /** + * Setter for database result instance + * + * @param $resultInstance An instance of a database result class + * @return void + * @todo SearchableResult and UpdateableResult shall have a super interface to use here + */ + protected final function setResultInstance (SearchableResult $resultInstance) { + $this->resultInstance = $resultInstance; + } + + /** + * Getter for database result instance + * + * @return $resultInstance An instance of a database result class + */ + public final function getResultInstance () { + return $this->resultInstance; + } + +} diff --git a/framework/main/traits/streamer/file/input/class_FileInputStreamerTrait.php b/framework/main/traits/streamer/file/input/class_FileInputStreamerTrait.php new file mode 100644 index 00000000..0e0b7b5e --- /dev/null +++ b/framework/main/traits/streamer/file/input/class_FileInputStreamerTrait.php @@ -0,0 +1,55 @@ + + * @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 . + */ +trait FileInputStreamerTrait { + /** + * The *real* file input class we shall use for reading data + */ + private $inputStreamerInstance = NULL; + + /** + * Setter for the *real* file input instance + * + * @param $inputStreamerInstance The *real* file-input class + * @return void + */ + public final function setInputStreamerInstance (FileInputStreamer $inputStreamerInstance) { + $this->inputStreamerInstance = $inputStreamerInstance; + } + + /** + * Getter for the *real* file input instance + * + * @return $inputStreamerInstance The *real* file-input class + */ + public final function getInputStreamerInstance () { + return $this->inputStreamerInstance; + } + +} diff --git a/framework/main/traits/streamer/file/output/class_FileOutputStreamerTrait.php b/framework/main/traits/streamer/file/output/class_FileOutputStreamerTrait.php new file mode 100644 index 00000000..39b225ff --- /dev/null +++ b/framework/main/traits/streamer/file/output/class_FileOutputStreamerTrait.php @@ -0,0 +1,55 @@ + + * @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 . + */ +trait FileOutputStreamerTrait { + /** + * The *real* file output class we shall use for reading data + */ + private $outputStreamerInstance = NULL; + + /** + * Setter for the *real* file output instance + * + * @param $outputStreamerInstance The *real* file-output class + * @return void + */ + public final function setOutputStreamerInstance (FileOutputStreamer $outputStreamerInstance) { + $this->outputStreamerInstance = $outputStreamerInstance; + } + + /** + * Getter for the *real* file output instance + * + * @return $outputStreamerInstance The *real* file-output class + */ + public final function getOutputStreamerInstance () { + return $this->outputStreamerInstance; + } + +} diff --git a/framework/main/traits/streamer/output/class_OutputStreamerTrait.php b/framework/main/traits/streamer/output/class_OutputStreamerTrait.php new file mode 100644 index 00000000..9171cdc6 --- /dev/null +++ b/framework/main/traits/streamer/output/class_OutputStreamerTrait.php @@ -0,0 +1,55 @@ + + * @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 . + */ +trait OutputStreamerTrait { + /** + * The concrete output instance + */ + private $outputInstance = NULL; + + /** + * Setter for output instance + * + * @param $outputInstance The debug output instance + * @return void + */ + protected final function setOutputInstance (OutputStreamer $outputInstance) { + $this->outputInstance = $outputInstance; + } + + /** + * Getter for output instance + * + * @return $outputInstance The debug output instance + */ + protected final function getOutputInstance () { + return $this->outputInstance; + } + +} -- 2.39.2