You are here

public function EntityNormalizer::__construct in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/serialization/src/Normalizer/EntityNormalizer.php \Drupal\serialization\Normalizer\EntityNormalizer::__construct()
  2. 10 core/modules/serialization/src/Normalizer/EntityNormalizer.php \Drupal\serialization\Normalizer\EntityNormalizer::__construct()

Constructs an EntityNormalizer object.

Parameters

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

\Drupal\Core\Entity\EntityTypeRepositoryInterface $entity_type_repository: The entity type repository.

\Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager: The entity field manager.

File

core/modules/serialization/src/Normalizer/EntityNormalizer.php, line 34

Class

EntityNormalizer
Normalizes/denormalizes Drupal entity objects into an array structure.

Namespace

Drupal\serialization\Normalizer

Code

public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeRepositoryInterface $entity_type_repository = NULL, EntityFieldManagerInterface $entity_field_manager = NULL) {
  $this->entityTypeManager = $entity_type_manager;
  if (!$entity_type_repository) {
    @trigger_error('The entity_type.repository service must be passed to EntityNormalizer::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
    $entity_type_repository = \Drupal::service('entity_type.repository');
  }
  $this->entityTypeRepository = $entity_type_repository;
  if (!$entity_field_manager) {
    @trigger_error('The entity_field.manager service must be passed to EntityNormalizer::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
    $entity_field_manager = \Drupal::service('entity_field.manager');
  }
  $this->entityFieldManager = $entity_field_manager;
}