]> _ Git - fluidbook_tools.git/commitdiff
wip #5661
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 20 Dec 2022 07:04:25 +0000 (08:04 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 20 Dec 2022 07:04:25 +0000 (08:04 +0100)
src/Links/Link.php

index 81cd964451ac51381eb841fb844decad97435bd0..b7a731b264ec3769b6e1cb25d5db64ec65bda0e3 100644 (file)
@@ -636,12 +636,6 @@ class Link {
      * @throws \SodiumException
      */
     public static function decryptLink($link) {
-        $array = false;
-        if (is_array($link)) {
-            $array = true;
-            $link = ObjectUtil::asObject($link);
-        }
-
         foreach ($link as $attr => $item) {
             if (!str_starts_with($item, '///')) {
                 continue;
@@ -649,15 +643,12 @@ class Link {
             $v = Crypt::safeDecrypt(substr($item, 3), self::_getLinkKey());
             $e = explode('|||', $v);
             if ($e[0] === $link->uid) {
-                $link->$attr = $e[1];
+                $link[$attr] = $e[1];
             } else {
-                $link->$attr = '';
+                $link[$attr] = '';
             }
         }
-        if (!$array) {
-            return $link;
-        }
-        return ArrayUtil::asArray($link);
+        return $link;
     }
 
     public static function decryptLinks($links) {
@@ -683,26 +674,22 @@ class Link {
      */
     public static function encryptLinkAttrs($link)
     {
-        if (is_array($link)) {
-            $link = ObjectUtil::asObject($link);
-        }
-
         $crypted = [13, 14, 35];
 
-        if (!isset($link->type) || !in_array($link->type, $crypted)) {
+        if (!isset($link['type']) || !in_array($link['type'], $crypted)) {
             return $link;
         }
 
         $attrs = ['image_rollover'];
         foreach ($attrs as $attr) {
-            if (!isset($link->$attr)) {
+            if (!isset($link[$attr])) {
                 continue;
             }
-            $link->$attr = trim($link->$attr);
-            if (str_starts_with($link->$attr, '///') || $link->$attr == '') {
+            $link[$attr] = trim($link[$attr]);
+            if (str_starts_with($link[$attr], '///') || $link[$attr] == '') {
                 continue;
             }
-            $link->$attr = '///' . Crypt::safeEncrypt($link->uid . '|||' . $link->$attr, self::_getLinkKey());
+            $link[$attr] = '///' . Crypt::safeEncrypt($link['uid'] . '|||' . $link[$attr], self::_getLinkKey());
         }
         return $link;
     }