Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 18 |
| Taxonomy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 18 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| create | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
| title | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 8 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\taxonomy\Plugin\views\argument\Taxonomy. | |
| */ | |
| 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; | |
| /** | |
| * Argument handler for basic taxonomy tid. | |
| * | |
| * @ingroup views_argument_handlers | |
| * | |
| * @ViewsArgument("taxonomy") | |
| */ | |
| class Taxonomy extends NumericArgument implements ContainerFactoryPluginInterface { | |
| /** | |
| * @var EntityStorageInterface | |
| */ | |
| protected $termStorage; | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $term_storage) { | |
| parent::__construct($configuration, $plugin_id, $plugin_definition); | |
| $this->termStorage = $term_storage; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| 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') | |
| ); | |
| } | |
| /** | |
| * Override the behavior of title(). Get the title of the node. | |
| */ | |
| function title() { | |
| // There might be no valid argument. | |
| if ($this->argument) { | |
| $term = $this->termStorage->load($this->argument); | |
| if (!empty($term)) { | |
| return $term->getName(); | |
| } | |
| } | |
| // TODO review text | |
| return $this->t('No name'); | |
| } | |
| } |