Currency.php in Price 2.x
File
src/Plugin/views/filter/Currency.php
View source
<?php
namespace Drupal\price\Plugin\views\filter;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\views\Plugin\views\filter\InOperator;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Currency extends InOperator {
protected $entityTypeManager;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entity_type_manager;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager'));
}
public function getValueOptions() {
if (!isset($this->valueOptions)) {
$currency_storage = $this->entityTypeManager
->getStorage('price_currency');
$currencies = $currency_storage
->loadMultiple();
$currency_codes = array_keys($currencies);
$this->valueOptions = array_combine($currency_codes, $currency_codes);
}
return $this->valueOptions;
}
}