]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 29 Jan 2025 14:46:20 +0000 (15:46 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 29 Jan 2025 14:46:20 +0000 (15:46 +0100)
- introduced LocalSearchCriteriaTrait
- updated index.php (generic!)

framework/main/classes/criteria/dataset/class_DataSetCriteria.php
framework/main/classes/criteria/update/class_UpdateCriteria.php
framework/main/traits/criteria/search/class_LocalSearchCriteraTrait.php [new file with mode: 0644]
index.php

index 88e49dda27759a5b441dbe6592140d743bebd966..8ad27895f3064702bb0b715b03a65e5d771e746b 100644 (file)
@@ -4,9 +4,9 @@ namespace Org\Mxchange\CoreFramework\Criteria\DataSet;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Criteria\BaseCriteria;
-use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
 use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Traits\Criteria\Local\LocalSearchCriteriaTrait;
 
 // Import SPL stuff
 use \BadMethodCallException;
@@ -35,6 +35,9 @@ use \InvalidArgumentException;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class DataSetCriteria extends BaseCriteria implements StoreableCriteria {
+       // Load traits
+       use LocalSearchCriteriaTrait;
+
        /**
         * Table name
         */
@@ -55,11 +58,6 @@ class DataSetCriteria extends BaseCriteria implements StoreableCriteria {
         */
        private $primaryKeys = [];
 
-       /**
-        * Search criteria instance
-        */
-       private $searchInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -164,25 +162,6 @@ class DataSetCriteria extends BaseCriteria implements StoreableCriteria {
                return $this->primaryKeys;
        }
 
-       /**
-        * Setter for search instance
-        *
-        * @param       $searchInstance         Searchable criteria instance
-        * @return      void
-        */
-       public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
-               $this->searchInstance = $searchInstance;
-       }
-
-       /**
-        * Getter for search instance
-        *
-        * @return      $searchInstance         Searchable criteria instance
-        */
-       public final function getSearchInstance () {
-               return $this->searchInstance;
-       }
-
        /**
         * Getter for unique key value
         *
index f177543c87567aea3f464659b31a9bebd22eded2..aa326181fe424bbd43b6f30d4507001ebf56dfa0 100644 (file)
@@ -4,7 +4,7 @@ namespace Org\Mxchange\CoreFramework\Criteria\Update;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Criteria\BaseCriteria;
-use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
+use Org\Mxchange\CoreFramework\Traits\Criteria\Local\LocalSearchCriteriaTrait;
 use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria;
 
 /**
@@ -32,10 +32,8 @@ use Org\Mxchange\CoreFramework\Criteria\Local\LocalUpdateCriteria;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class UpdateCriteria extends BaseCriteria implements LocalUpdateCriteria {
-       /**
-        * Search criteria instance
-        */
-       private $searchInstance = NULL;
+       // Load traits
+       use LocalSearchCriteriaTrait;
 
        /**
         * Protected constructor
@@ -71,23 +69,4 @@ class UpdateCriteria extends BaseCriteria implements LocalUpdateCriteria {
                return $this->getCriteriaArray();
        }
 
-       /**
-        * Setter for search instance
-        *
-        * @param       $searchInstance         Searchable criteria instance
-        * @return      void
-        */
-       public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
-               $this->searchInstance = $searchInstance;
-       }
-
-       /**
-        * Getter for search instance
-        *
-        * @return      $searchInstance         Searchable criteria instance
-        */
-       public final function getSearchInstance () {
-               return $this->searchInstance;
-       }
-
 }
diff --git a/framework/main/traits/criteria/search/class_LocalSearchCriteraTrait.php b/framework/main/traits/criteria/search/class_LocalSearchCriteraTrait.php
new file mode 100644 (file)
index 0000000..f818313
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+// Own namespace
+namespace Org\Mxchange\CoreFramework\Traits\Criteria\Search;
+
+// Import application-specific stuff
+use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
+
+/**
+ * A trait for local storage criteria instances
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 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 LocalSearchCriteriaTrait {
+       /**
+        * Search criteria instance
+        */
+       private $searchInstance = NULL;
+
+       /**
+        * Setter for search instance
+        *
+        * @param       $searchInstance         Searchable criteria instance
+        * @return      void
+        */
+       public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
+               $this->searchInstance = $searchInstance;
+       }
+
+       /**
+        * Getter for search instance
+        *
+        * @return      $searchInstance         Searchable criteria instance
+        */
+       public final function getSearchInstance () {
+               return $this->searchInstance;
+       }
+
+}
index 37fa261279410afe592905650fe6afaa2af5454c..6a499bba830d795c91362866440421e1ba6a32e4 100644 (file)
--- a/index.php
+++ b/index.php
@@ -58,7 +58,7 @@ final class ApplicationEntryPoint {
         * @return      void
         * @todo        This method is old code and needs heavy rewrite and should be moved to ApplicationHelper
         */
-       public static final function exitApplication (string $message = '', int $code = -1, string $extraData = '', bool $silentMode = false) {
+       public static final function exitApplication (string $message = '', int $code = -1, string $extraData = '', bool $silentMode = false): void {
                // Is this method already called?
                //* NOISY-DEBUG: */ printf('[%s:%d]: message=%s,code=%d,extraData=%s,silentMode=%d - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $message, $code, $extraData, intval($silentMode));
                if (isset($GLOBALS['app_die_called'])) {
@@ -200,7 +200,7 @@ final class ApplicationEntryPoint {
         *
         * @return      $frameworkPath  Path for framework
         */
-       public static final function detectFrameworkPath () {
+       public static final function detectFrameworkPath (): string {
                // Is it not set?
                //* NOISY-DEBUG: */ printf('[%s:%d]: self::frameworkPath=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, self::$frameworkPath);
                if (empty(self::$frameworkPath)) {
@@ -255,7 +255,7 @@ final class ApplicationEntryPoint {
         *
         * @return      $rootPath       Root path
         */
-       public static function getRootPath () {
+       public static function getRootPath (): string {
                // Get __DIR__, really simple and no detection
                return __DIR__;
        }
@@ -268,7 +268,7 @@ final class ApplicationEntryPoint {
         *
         * @return      void
         */
-       public static final function main () {
+       public static final function main (): void {
                // Load bootstrap file
                //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
                require sprintf('%sbootstrap%sbootstrap.inc.php', self::detectFrameworkPath(), DIRECTORY_SEPARATOR);