class ViewsEntityArgumentValidator

Same name in other branches
  1. 8.9.x core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php \Drupal\views\Plugin\Derivative\ViewsEntityArgumentValidator
  2. 10 core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php \Drupal\views\Plugin\Derivative\ViewsEntityArgumentValidator
  3. 11.x core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php \Drupal\views\Plugin\Derivative\ViewsEntityArgumentValidator

Provides views argument validator plugin definitions for all entity types.

Hierarchy

Expanded class hierarchy of ViewsEntityArgumentValidator

See also

\Drupal\views\Plugin\views\argument_validator\Entity

File

core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php, line 19

Namespace

Drupal\views\Plugin\Derivative
View source
class ViewsEntityArgumentValidator extends DeriverBase implements ContainerDeriverInterface {
    use StringTranslationTrait;
    
    /**
     * The base plugin ID this derivative is for.
     *
     * @var string
     */
    protected $basePluginId;
    
    /**
     * The entity type manager.
     *
     * @var \Drupal\Core\Entity\EntityTypeManagerInterface
     */
    protected $entityTypeManager;
    
    /**
     * List of derivative definitions.
     *
     * @var array
     */
    protected $derivatives = [];
    
    /**
     * Constructs a ViewsEntityArgumentValidator object.
     *
     * @param string $base_plugin_id
     *   The base plugin ID.
     * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
     *   The entity type manager.
     * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
     *   The string translation.
     */
    public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation) {
        $this->basePluginId = $base_plugin_id;
        $this->entityTypeManager = $entity_type_manager;
        $this->stringTranslation = $string_translation;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, $base_plugin_id) {
        return new static($base_plugin_id, $container->get('entity_type.manager'), $container->get('string_translation'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDerivativeDefinitions($base_plugin_definition) {
        $entity_types = $this->entityTypeManager
            ->getDefinitions();
        $this->derivatives = [];
        foreach ($entity_types as $entity_type_id => $entity_type) {
            $this->derivatives[$entity_type_id] = [
                'id' => 'entity:' . $entity_type_id,
                'provider' => 'views',
                'title' => $entity_type->getLabel(),
                'help' => $this->t('Validate @label', [
                    '@label' => $entity_type->getLabel(),
                ]),
                'entity_type' => $entity_type_id,
                'class' => $base_plugin_definition['class'],
            ];
        }
        return $this->derivatives;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
ViewsEntityArgumentValidator::$basePluginId protected property The base plugin ID this derivative is for.
ViewsEntityArgumentValidator::$derivatives protected property List of derivative definitions. Overrides DeriverBase::$derivatives
ViewsEntityArgumentValidator::$entityTypeManager protected property The entity type manager.
ViewsEntityArgumentValidator::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
ViewsEntityArgumentValidator::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
ViewsEntityArgumentValidator::__construct public function Constructs a ViewsEntityArgumentValidator object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.