From 2b53135db51e8a28cd0e83b72fc6540cd061d5bc Mon Sep 17 00:00:00 2001
From: GoZ <goz@226961.no-reply.drupal.org>
Date: Wed, 13 Jan 2016 10:25:09 +0100
Subject: [PATCH] Issue #2610220 by GoZ: Create a views argument plugin for
 filtering by active store

---
 .../store/config/schema/commerce_store.schema.yml  |  4 +++
 .../Plugin/views/argument_default/CurrentStore.php | 33 ++++++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 modules/store/src/Plugin/views/argument_default/CurrentStore.php

diff --git a/modules/store/config/schema/commerce_store.schema.yml b/modules/store/config/schema/commerce_store.schema.yml
index b334ccb..e3c8a70 100644
--- a/modules/store/config/schema/commerce_store.schema.yml
+++ b/modules/store/config/schema/commerce_store.schema.yml
@@ -28,3 +28,7 @@ views.field.store:
     hide_single_store:
       type: boolean
       label: 'Hide if there''s only one store.'
+
+views.argument_default.current_store:
+  type: boolean
+  label: 'Store UUID from current store'
diff --git a/modules/store/src/Plugin/views/argument_default/CurrentStore.php b/modules/store/src/Plugin/views/argument_default/CurrentStore.php
new file mode 100644
index 0000000..c5a5bd3
--- /dev/null
+++ b/modules/store/src/Plugin/views/argument_default/CurrentStore.php
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\commerce_store\Plugin\views\argument_default\CurrentStore.
+ */
+
+namespace Drupal\commerce_store\Plugin\views\argument_default;
+
+use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
+
+/**
+ * Default argument plugin to extract the current store
+ *
+ * This plugin actually has no options so it odes not need to do a great deal.
+ *
+ * @ViewsArgumentDefault(
+ *   id = "current_store",
+ *   title = @Translation("Store UUID from current store")
+ * )
+ */
+class CurrentStore extends ArgumentDefaultPluginBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getArgument() {
+    $storeContext = \Drupal::service('commerce_store.store_context');
+    $store = $storeContext->getStore();
+    return $store->id();
+  }
+
+}
-- 
2.5.4 (Apple Git-61)

