TaxonomyEntityIndexUuidDepth.php in Taxonomy Entity Index 8
File
src/Plugin/views/argument/TaxonomyEntityIndexUuidDepth.php
View source
<?php
namespace Drupal\taxonomy_entity_index\Plugin\views\argument;
use Drupal\Component\Uuid\Uuid;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class TaxonomyEntityIndexUuidDepth extends TaxonomyEntityIndexDepth {
protected $entityRepository;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $termStorage, Connection $database, EntityRepositoryInterface $entityRepository) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $termStorage, $database);
$this->entityRepository = $entityRepository;
}
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('taxonomy_term'), $container
->get('database'), $container
->get('entity.repository'));
}
protected function convertIdsToEntityIds($ids) {
if (!is_array($ids)) {
$ids = [
$ids,
];
}
$entity_ids = [];
$entity_type = $this->termStorage
->getEntityTypeId();
foreach ($ids as $uuid) {
if (!Uuid::isValid($uuid) || !($entity = $this->entityRepository
->loadEntityByUuid($entity_type, $uuid))) {
continue;
}
$entity_ids[] = $entity
->id();
}
return $entity_ids;
}
}