ViewsEntityArgumentValidator.php in Zircon Profile 8
File
core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php
View source
<?php
namespace Drupal\views\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ViewsEntityArgumentValidator extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
protected $basePluginId;
protected $entityManager;
protected $derivatives = array();
public function __construct($base_plugin_id, EntityManagerInterface $entity_manager, TranslationInterface $string_translation) {
$this->basePluginId = $base_plugin_id;
$this->entityManager = $entity_manager;
$this->stringTranslation = $string_translation;
}
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('entity.manager'), $container
->get('string_translation'));
}
public function getDerivativeDefinitions($base_plugin_definition) {
$entity_types = $this->entityManager
->getDefinitions();
$this->derivatives = array();
foreach ($entity_types as $entity_type_id => $entity_type) {
$this->derivatives[$entity_type_id] = array(
'id' => 'entity:' . $entity_type_id,
'provider' => 'views',
'title' => $entity_type
->getLabel(),
'help' => $this
->t('Validate @label', array(
'@label' => $entity_type
->getLabel(),
)),
'entity_type' => $entity_type_id,
'class' => $base_plugin_definition['class'],
);
}
return $this->derivatives;
}
}