From f4244499555f3e7b224c631be280d2357a1edb59 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 19 Oct 2023 11:01:36 +0200 Subject: [PATCH] wait #6427 @0.25 --- .../Tools/FluidbookReferencesURL.php | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Admin/Operations/Tools/FluidbookReferencesURL.php b/app/Http/Controllers/Admin/Operations/Tools/FluidbookReferencesURL.php index 3b7b807d6..3bec36008 100644 --- a/app/Http/Controllers/Admin/Operations/Tools/FluidbookReferencesURL.php +++ b/app/Http/Controllers/Admin/Operations/Tools/FluidbookReferencesURL.php @@ -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) -- 2.39.5