[TikiWiki-commits] [Git][tikiwiki/tiki][master] [REF] PSR12 Migration Changes For Tiki_Profile_SymbolLoader

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68912bc1ef016_2cd5cdc-346@gitlab-sidekiq-low-urgency-cpu-bound-v2-58b475bb65-ps75b.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
bea4e1b3 by Sandeep D at 2025-08-04T21:13:40+00:00
[REF] PSR12 Migration Changes For Tiki_Profile_SymbolLoader
---
* [REF] PSR12 Migration Changes For Tiki_Profile_SymbolLoader

See merge request tikiwiki/tiki!8156

- - - - -


8 changed files:

- .gitattributes
- .phpstorm.meta.php
- db/config/tiki.xml
- doc/devtools/codesniffer/standards/TikiIgnore/ignore_list.json
- lib/core/Tiki/PSR12Migration/Autoload.php
- lib/core/Tiki/Profile/SymbolLoader.php
- + lib/core/Tiki/Profile/SymbolLoaderStore.php
- lib/tikilib.php


Changes:

=====================================
.gitattributes
=====================================
@@ -3052,6 +3052,7 @@ lib/core/Tiki/Profile/Installer.php -text
 lib/core/Tiki/Profile/List.php -text
 lib/core/Tiki/Profile/Object.php -text
 lib/core/Tiki/Profile/SymbolLoader.php -text
+lib/core/Tiki/Profile/SymbolLoaderStore.php -text
 lib/core/Tiki/Profile/Transport/File.php -text
 lib/core/Tiki/Profile/Transport/Interface.php -text
 lib/core/Tiki/Profile/Transport/Local.php -text


=====================================
.phpstorm.meta.php
=====================================
@@ -118,7 +118,7 @@ namespace PHPSTORM_META {
             'stats'                      => \StatsLib::class,
             'storedsearch'               => \StoredSearchLib::class,
             'struct'                     => \StructLib::class,
-            'symbols'                    => \Tiki_Profile_SymbolLoader::class,
+            'symbols'                    => \Tiki\Profile\SymbolLoader::class,
             'tabular'                    => \Tracker\Tabular\Manager::class,
             'template'                   => \TemplatesLib::class,
             'theme'                      => \Tiki\Lib\Theme\ThemeLib::class,


=====================================
db/config/tiki.xml
=====================================
@@ -303,7 +303,7 @@
         <service id="tiki.lib.struct" class="StructLib">
             <file>%kernel.root_dir%/lib/structures/structlib.php</file>
         </service>
-        <service id="tiki.lib.symbols" class="Tiki_Profile_SymbolLoader" />
+        <service id="tiki.lib.symbols" class="Tiki\Profile\SymbolLoader" />
         <service id="tiki.lib.tabular" class="Tracker\Tabular\Manager">
             <argument type="service" id="tiki.lib.db"/>
         </service>


=====================================
doc/devtools/codesniffer/standards/TikiIgnore/ignore_list.json
=====================================
@@ -1351,10 +1351,6 @@
         "lib\/core\/Tiki\/Profile\/DateConverter.php": {
             "class:Tiki_Profile_DateConverter": true
         },
-        "lib\/core\/Tiki\/Profile\/SymbolLoader.php": {
-            "class:Tiki_Profile_SymbolLoader": true,
-            "class:Tiki_Profile_SymbolLoader_Store": true
-        },
         "lib\/core\/Tiki\/Profile\/List.php": {
             "class:Tiki_Profile_List": true
         },
@@ -4933,10 +4929,6 @@
         "lib\/core\/Tiki\/Profile\/DateConverter.php": {
             "Tiki_Profile_DateConverter": true
         },
-        "lib\/core\/Tiki\/Profile\/SymbolLoader.php": {
-            "Tiki_Profile_SymbolLoader": true,
-            "Tiki_Profile_SymbolLoader_Store": true
-        },
         "lib\/core\/Tiki\/Profile\/List.php": {
             "Tiki_Profile_List": true
         },
@@ -6268,9 +6260,6 @@
         }
     },
     "PSR1.Classes.ClassDeclaration.MultipleClasses": {
-        "lib\/core\/Tiki\/Profile\/SymbolLoader.php": {
-            "class:Tiki_Profile_SymbolLoader_Store": true
-        },
         "lib\/cache\/cachelib.php": {
             "class:CacheLibFileSystem": true,
             "class:CacheLibMemcache": true,


=====================================
lib/core/Tiki/PSR12Migration/Autoload.php
=====================================
@@ -155,6 +155,8 @@ class Autoload
         'Tiki_Security_Policy' => 'Tiki\\Smarty\\SecurityPolicy',
         'Smarty_Tiki' => 'Tiki\\Smarty\\SmartyTiki',
         'SmartyTikiErrorHandler' => 'Tiki\\Smarty\\SmartyTikiErrorHandler',
+        'Tiki_Profile_SymbolLoader' => 'Tiki\\Profile\\SymbolLoader',
+        'Tiki_Profile_SymbolLoader_Store' => 'Tiki\\Profile\\SymbolLoaderStore',
         'TikiDate' => 'Tiki\\Lib\\TikiDate',
         'Date_Calc' => 'Tiki\\Lib\\DateCalc',
     ];


=====================================
lib/core/Tiki/Profile/SymbolLoader.php
=====================================
@@ -4,6 +4,10 @@
 //
 // All Rights Reserved. See copyright.txt for details and a complete list of authors.
 // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+namespace Tiki\Profile;
+
+use ArrayAccess;
+
 /**
  * Dynamically loads and caches profile symbols for usage in templates.
  *
@@ -16,7 +20,7 @@
  * Smarty: {$symbols->Profile_Name_Here.some_name}
  * PHP: $symbols->Profile_Name_Here['some_name']
  */
-class Tiki_Profile_SymbolLoader implements ArrayAccess
+class SymbolLoader implements ArrayAccess
 {
     private $store;
     private $filters;
@@ -24,7 +28,7 @@ class Tiki_Profile_SymbolLoader implements ArrayAccess
 
     public function __construct($store = null, ?array $filters = null, array $nextFilters = ['profile', 'domain'])
     {
-        $this->store = $store ?: new Tiki_Profile_SymbolLoader_Store();
+        $this->store = $store ?: new SymbolLoaderStore();
         $this->nextFilters = $nextFilters;
         $this->filters = $filters ?: [
             'profile' => '',
@@ -60,55 +64,3 @@ class Tiki_Profile_SymbolLoader implements ArrayAccess
         }
     }
 }
-
-class Tiki_Profile_SymbolLoader_Store
-{
-    public const KEY = 'profile_symbols_lookup';
-    private $data = false;
-
-    public function get($name, $filters)
-    {
-        $this->loadData();
-        $profile = $filters['profile'];
-        $domain = $filters['domain'];
-
-        if (! isset($this->data[$domain][$profile][$name])) {
-            $this->data[$domain][$profile][$name] = $this->fetch($name, $filters);
-
-            // Storage should be done at most once per request, but this will only be possible
-            // in 13 reliably
-            $this->storeData();
-        }
-
-        return $this->data[$domain][$profile][$name];
-    }
-
-    public function fetch($name, $filters)
-    {
-        $filters = array_filter($filters);
-        $filters['object'] = $name;
-
-        $table = TikiDb::get()->table('tiki_profile_symbols');
-        return $table->fetchOne('value', $filters, 'creation_date_desc');
-    }
-
-    private function loadData()
-    {
-        if ($this->data !== false) {
-            return;
-        }
-
-        $cache = TikiLib::lib('cache');
-        if (! $data = $cache->getSerialized(self::KEY)) {
-            $data = [];
-        }
-
-        $this->data = $data;
-    }
-
-    private function storeData()
-    {
-        $cache = TikiLib::lib('cache');
-        $cache->cacheItem(self::KEY, serialize($this->data));
-    }
-}


=====================================
lib/core/Tiki/Profile/SymbolLoaderStore.php
=====================================
@@ -0,0 +1,62 @@
+<?php
+
+// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
+//
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+namespace Tiki\Profile;
+
+use TikiDb;
+use TikiLib;
+
+class SymbolLoaderStore
+{
+    public const KEY = 'profile_symbols_lookup';
+    private $data = false;
+
+    public function get($name, $filters)
+    {
+        $this->loadData();
+        $profile = $filters['profile'];
+        $domain = $filters['domain'];
+
+        if (! isset($this->data[$domain][$profile][$name])) {
+            $this->data[$domain][$profile][$name] = $this->fetch($name, $filters);
+
+            // Storage should be done at most once per request, but this will only be possible
+            // in 13 reliably
+            $this->storeData();
+        }
+
+        return $this->data[$domain][$profile][$name];
+    }
+
+    public function fetch($name, $filters)
+    {
+        $filters = array_filter($filters);
+        $filters['object'] = $name;
+
+        $table = TikiDb::get()->table('tiki_profile_symbols');
+        return $table->fetchOne('value', $filters, 'creation_date_desc');
+    }
+
+    private function loadData()
+    {
+        if ($this->data !== false) {
+            return;
+        }
+
+        $cache = TikiLib::lib('cache');
+        if (! $data = $cache->getSerialized(self::KEY)) {
+            $data = [];
+        }
+
+        $this->data = $data;
+    }
+
+    private function storeData()
+    {
+        $cache = TikiLib::lib('cache');
+        $cache->cacheItem(self::KEY, serialize($this->data));
+    }
+}


=====================================
lib/tikilib.php
=====================================
@@ -107,7 +107,7 @@ class TikiLib extends TikiDb_Bridge
     }
 
     /**
-     * @return Tiki_Profile_SymbolLoader
+     * @return Tiki\Profile\SymbolLoader
      * @throws Exception
      */
     public static function symbols()



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/bea4e1b37331ce3985c2e9f5f9456270bbc76f2d

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/bea4e1b37331ce3985c2e9f5f9456270bbc76f2d
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.