function EntityArgument::__construct

Same name in other branches
  1. 11.x core/modules/views/src/Plugin/views/argument/EntityArgument.php \Drupal\views\Plugin\views\argument\EntityArgument::__construct()

Overrides HandlerBase::__construct

File

core/modules/views/src/Plugin/views/argument/EntityArgument.php, line 32

Class

EntityArgument
Argument handler to accept an entity ID value.

Namespace

Drupal\views\Plugin\views\argument

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityRepositoryInterface|EntityStorageInterface|EntityTypeManagerInterface $entityRepository, ?EntityTypeManagerInterface $entityTypeManager = NULL) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    if (!$entityRepository instanceof EntityRepositoryInterface) {
        @trigger_error('Passing either \\Drupal\\Core\\Entity\\EntityStorageInterface or \\Drupal\\Core\\Entity\\EntityTypeManagerInterface to ' . __METHOD__ . '() as argument 4 is deprecated in drupal:10.3.0 and will be removed before drupal:11.0.0. Pass a Drupal\\Core\\Entity\\EntityRepositoryInterface instead. See https://www.drupal.org/node/3441945', E_USER_DEPRECATED);
        $entityRepository = \Drupal::service('entity.repository');
    }
    $this->entityRepository = $entityRepository;
    if ($entityTypeManager === NULL) {
        @trigger_error('Not passing the \\Drupal\\Core\\Entity\\EntityTypeManagerInterface to ' . __METHOD__ . '() as argument 5 is deprecated in drupal:10.3.0 and will be required before drupal:11.0.0. See https://www.drupal.org/node/3441945', E_USER_DEPRECATED);
        $entityTypeManager = \Drupal::service('entity_type.manager');
    }
    $this->entityTypeManager = $entityTypeManager;
}

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