CurrentStore.php in Commerce Core 8.2
File
modules/store/src/Plugin/views/argument_default/CurrentStore.php
View source
<?php
namespace Drupal\commerce_store\Plugin\views\argument_default;
use Drupal\commerce_store\CurrentStoreInterface;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class CurrentStore extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {
protected $currentStore;
public function __construct(array $configuration, $plugin_id, $plugin_definition, CurrentStoreInterface $current_store) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->currentStore = $current_store;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('commerce_store.current_store'));
}
public function getArgument() {
return $this->currentStore
->getStore()
->id();
}
public function getCacheMaxAge() {
return Cache::PERMANENT;
}
public function getCacheContexts() {
return [
'store',
];
}
public function getCacheTags() {
return $this->currentStore
->getStore()
->getCacheTags();
}
}