Version 1
[yaffs-website] / web / modules / contrib / ctools / src / SerializableTempstoreFactory.php
diff --git a/web/modules/contrib/ctools/src/SerializableTempstoreFactory.php b/web/modules/contrib/ctools/src/SerializableTempstoreFactory.php
new file mode 100644 (file)
index 0000000..51cf02b
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+namespace Drupal\ctools;
+
+use Drupal\user\SharedTempStoreFactory;
+
+/**
+ * A factory for creating SerializableTempStore objects.
+ */
+class SerializableTempstoreFactory extends SharedTempStoreFactory {
+
+  /**
+   * {@inheritdoc}
+   */
+  function get($collection, $owner = NULL) {
+    // Use the currently authenticated user ID or the active user ID unless the
+    // owner is overridden.
+    if (!isset($owner)) {
+      $owner = \Drupal::currentUser()->id() ?: session_id();
+    }
+
+    // Store the data for this collection in the database.
+    $storage = $this->storageFactory->get("user.shared_tempstore.$collection");
+    return new SerializableTempstore($storage, $this->lockBackend, $owner, $this->requestStack, $this->expire);
+  }
+
+}