]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6427 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 19 Oct 2023 09:01:36 +0000 (11:01 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 19 Oct 2023 09:01:36 +0000 (11:01 +0200)
app/Http/Controllers/Admin/Operations/Tools/FluidbookReferencesURL.php

index 3b7b807d6e9921397aff27914c8862d6863c5aa3..3bec360086351ed750ca058b2ef11e29baaaca93 100644 (file)
@@ -28,10 +28,12 @@ trait FluidbookReferencesURL
         'joueclubnoel' => 'JouéClub Noël',
     ];
 
+    protected static $db = null;
+
     public static function isCustomLink($url)
     {
         $e = explode(':', trim($url));
-        return isset(static::$_db[trim($e[0])]);
+        return isset(static::getTypes()[trim($e[0])]);
     }
 
     public function fluidbookrefurl()
@@ -53,15 +55,26 @@ trait FluidbookReferencesURL
 
     protected function _getOptions()
     {
-        $keys = array_keys(self::$_db);
-        $res = self::$_db;
-        foreach (FluidbookReference::whereNotIn('type', $keys)->get() as $item) {
-            if (isset($res[$item->type])) {
-                continue;
+        return self::getTypes();
+    }
+
+    /**
+     * @return string[]
+     */
+    public static function getTypes()
+    {
+        if (null === static::$db) {
+            $keys = array_keys(static::$_db);
+            static::$db = static::$_db;
+            foreach (FluidbookReference::whereNotIn('type', $keys)->get() as $item) {
+                if (isset(static::$db[$item->type])) {
+                    continue;
+                }
+                static::$db[$item->type] = $item->type;
             }
-            $res[$item->type] = $item->type;
+
         }
-        return $res;
+        return static::$db;
     }
 
     protected static function _normalizeType($type)