Taxonomy.php in Zircon Profile 8
File
core/modules/taxonomy/src/Plugin/views/argument/Taxonomy.php
View source
<?php
namespace Drupal\taxonomy\Plugin\views\argument;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\views\Plugin\views\argument\NumericArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Taxonomy extends NumericArgument implements ContainerFactoryPluginInterface {
protected $termStorage;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $term_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->termStorage = $term_storage;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity.manager')
->getStorage('taxonomy_term'));
}
function title() {
if ($this->argument) {
$term = $this->termStorage
->load($this->argument);
if (!empty($term)) {
return $term
->getName();
}
}
return $this
->t('No name');
}
}
Classes
Name |
Description |
Taxonomy |
Argument handler for basic taxonomy tid. |