Country.php in Ubercart 8.4
File
uc_country/src/Plugin/views/field/Country.php
View source
<?php
namespace Drupal\uc_country\Plugin\views\field;
use Drupal\Core\Config\Entity\ConfigEntityStorageInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Country extends FieldPluginBase {
protected $countryStorage;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigEntityStorageInterface $country_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->countryStorage = $country_storage;
}
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')
->getStorage('uc_country'));
}
public function render(ResultRow $values) {
$value = $this
->getValue($values);
if ($value && ($country = $this->countryStorage
->load($value))) {
return $country
->label();
}
return '';
}
}
Classes
Name |
Description |
Country |
A handler to provide proper displays for country. |