[BUGFIX] Make `top.TYPO3.Storage` available again 04/54704/3
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 20 Nov 2017 18:13:17 +0000 (19:13 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Tue, 28 Nov 2017 10:23:59 +0000 (11:23 +0100)
`top.TYPO3.Storage` is now globally available again, it's not necessary to
load this module via RequireJS. Please keep in mind this module is
deprecated.

Resolves: #83049
Related: #82603
Releases: master
Change-Id: I72796f377063c683f024a223818a599edade5367
Reviewed-on: https://review.typo3.org/54704
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/backend/Classes/Controller/BackendController.php
typo3/sysext/backend/Resources/Private/TypeScript/Storage.ts
typo3/sysext/backend/Resources/Public/JavaScript/Storage.js

index 1dfc653..4ad2783 100644 (file)
@@ -155,6 +155,7 @@ class BackendController
         $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
 
         // load the storage API and fill the UC into the PersistentStorage, so no additional AJAX call is needed
+        $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Storage');
         $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Storage/Persistent', 'function(PersistentStorage) {
             PersistentStorage.load(' . json_encode($this->getBackendUser()->uc) . ');
         }');
index ae329c0..6c8a83f 100644 (file)
@@ -27,13 +27,71 @@ class Storage {
   public Persistent: any;
 
   constructor() {
+    this.Client = {
+      clear: (): any => {
+        this.logDeprecated('Client', 'clear');
+        Client.clear();
+      },
+      get: (key: string): any => {
+        this.logDeprecated('Client', 'get');
+        return Client.get(key);
+      },
+      isset: (key: string): any => {
+        this.logDeprecated('Client', 'isset');
+        return Client.isset(key);
+      },
+      set: (key: string, value: string): any => {
+        this.logDeprecated('Client', 'set');
+        return Client.set(key, value);
+      },
+      unset: (key: string): any => {
+        this.logDeprecated('Client', 'unset');
+        return Client.unset(key);
+      },
+    };
+    this.Persistent = {
+      addToList: (key: string, value: string): any => {
+        this.logDeprecated('Persistent', 'addToList');
+        return Persistent.addToList(key, value);
+      },
+      clear: (): any => {
+        this.logDeprecated('Persistent', 'clear');
+        Persistent.clear();
+      },
+      get: (key: string): any => {
+        this.logDeprecated('Persistent', 'get');
+        return Persistent.get(key);
+      },
+      isset: (key: string): any => {
+        this.logDeprecated('Persistent', 'isset');
+        return Persistent.isset(key);
+      },
+      load: (data: any): any => {
+        this.logDeprecated('Persistent', 'load');
+        return Persistent.load(data);
+      },
+      removeFromList: (key: string, value: string): any => {
+        this.logDeprecated('Persistent', 'removeFromList');
+        return Persistent.removeFromList(key, value);
+      },
+      set: (key: string, value: string): any => {
+        this.logDeprecated('Persistent', 'set');
+        return Persistent.set(key, value);
+      },
+      unset: (key: string): any => {
+        this.logDeprecated('Persistent', 'unset');
+        return Persistent.unset(key);
+      },
+    };
+  }
+
+  private logDeprecated = (className: string, methodName: string): any => {
     if (console) {
       console.warn(
-        'TYPO3/CMS/Backend/Storage and TYPO3.Storage are deprecated since TYPO3 v9 and will be removed in TYPO3 v10.',
+        'top.TYPO3.Storage.' + className + '.' + methodName + '() is marked as deprecated since TYPO3 v9 and will be '
+        + 'removed in TYPO3 v10.',
       );
     }
-    this.Client = Client;
-    this.Persistent = Persistent;
   }
 }
 
index bf48117..5c891e0 100644 (file)
@@ -22,11 +22,69 @@ define(["require", "exports", "./Storage/Client", "./Storage/Persistent"], funct
      */
     var Storage = (function () {
         function Storage() {
-            if (console) {
-                console.warn('TYPO3/CMS/Backend/Storage and TYPO3.Storage are deprecated since TYPO3 v9 and will be removed in TYPO3 v10.');
-            }
-            this.Client = Client;
-            this.Persistent = Persistent;
+            var _this = this;
+            this.logDeprecated = function (className, methodName) {
+                if (console) {
+                    console.warn('top.TYPO3.Storage.' + className + '.' + methodName + '() is marked as deprecated since TYPO3 v9 and will be '
+                        + 'removed in TYPO3 v10.');
+                }
+            };
+            this.Client = {
+                clear: function () {
+                    _this.logDeprecated('Client', 'clear');
+                    Client.clear();
+                },
+                get: function (key) {
+                    _this.logDeprecated('Client', 'get');
+                    return Client.get(key);
+                },
+                isset: function (key) {
+                    _this.logDeprecated('Client', 'isset');
+                    return Client.isset(key);
+                },
+                set: function (key, value) {
+                    _this.logDeprecated('Client', 'set');
+                    return Client.set(key, value);
+                },
+                unset: function (key) {
+                    _this.logDeprecated('Client', 'unset');
+                    return Client.unset(key);
+                },
+            };
+            this.Persistent = {
+                addToList: function (key, value) {
+                    _this.logDeprecated('Persistent', 'addToList');
+                    return Persistent.addToList(key, value);
+                },
+                clear: function () {
+                    _this.logDeprecated('Persistent', 'clear');
+                    Persistent.clear();
+                },
+                get: function (key) {
+                    _this.logDeprecated('Persistent', 'get');
+                    return Persistent.get(key);
+                },
+                isset: function (key) {
+                    _this.logDeprecated('Persistent', 'isset');
+                    return Persistent.isset(key);
+                },
+                load: function (data) {
+                    _this.logDeprecated('Persistent', 'load');
+                    return Persistent.load(data);
+                },
+                removeFromList: function (key, value) {
+                    _this.logDeprecated('Persistent', 'removeFromList');
+                    return Persistent.removeFromList(key, value);
+                },
+                set: function (key, value) {
+                    _this.logDeprecated('Persistent', 'set');
+                    return Persistent.set(key, value);
+                },
+                unset: function (key) {
+                    _this.logDeprecated('Persistent', 'unset');
+                    return Persistent.unset(key);
+                },
+            };
         }
         return Storage;
     }());