function EntityConverter::__construct

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/ParamConverter/EntityConverter.php \Drupal\Core\ParamConverter\EntityConverter::__construct()
  2. 10 core/lib/Drupal/Core/ParamConverter/EntityConverter.php \Drupal\Core\ParamConverter\EntityConverter::__construct()
  3. 11.x core/lib/Drupal/Core/ParamConverter/EntityConverter.php \Drupal\Core\ParamConverter\EntityConverter::__construct()

Constructs a new EntityConverter.

Parameters

\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.

\Drupal\Core\Entity\EntityRepositoryInterface $entity_repository: The entity repository.

See also

https://www.drupal.org/node/2549139

https://www.drupal.org/node/2938929

1 call to EntityConverter::__construct()
AdminPathConfigEntityConverter::__construct in core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php
Constructs a new EntityConverter.
1 method overrides EntityConverter::__construct()
AdminPathConfigEntityConverter::__construct in core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php
Constructs a new EntityConverter.

File

core/lib/Drupal/Core/ParamConverter/EntityConverter.php, line 106

Class

EntityConverter
Parameter converter for upcasting entity IDs to full objects.

Namespace

Drupal\Core\ParamConverter

Code

public function __construct(EntityTypeManagerInterface $entity_type_manager, $entity_repository = NULL) {
    if ($entity_type_manager instanceof EntityManagerInterface) {
        @trigger_error('Passing the entity.manager service to EntityConverter::__construct() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Pass the entity_type.manager service instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
    }
    $this->entityTypeManager = $entity_type_manager;
    if (!$entity_repository instanceof EntityRepositoryInterface) {
        @trigger_error('Calling EntityConverter::__construct() with the $entity_repository argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
        $entity_repository = \Drupal::service('entity.repository');
    }
    $this->entityRepository = $entity_repository;
}

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