You are here

class TaxonomyTermNormalizer in Replication 8.2

Same name and namespace in other branches
  1. 8 src/Normalizer/TaxonomyTermNormalizer.php \Drupal\replication\Normalizer\TaxonomyTermNormalizer

Hierarchy

Expanded class hierarchy of TaxonomyTermNormalizer

1 string reference to 'TaxonomyTermNormalizer'
replication.services.yml in ./replication.services.yml
replication.services.yml
1 service uses TaxonomyTermNormalizer
replication.normalizer.taxonomy_term in ./replication.services.yml
Drupal\replication\Normalizer\TaxonomyTermNormalizer

File

src/Normalizer/TaxonomyTermNormalizer.php, line 7

Namespace

Drupal\replication\Normalizer
View source
class TaxonomyTermNormalizer extends ContentEntityNormalizer {

  /**
   * @var string[]
   */
  protected $supportedInterfaceOrClass = [
    '\\Drupal\\taxonomy\\Entity\\Term',
  ];

  /**
   * {@inheritdoc}
   */
  public function normalize($entity, $format = NULL, array $context = []) {
    $storage = $this->entityManager
      ->getStorage($entity
      ->getEntityTypeId());
    if (!isset($entity->parent->target_id)) {
      $parents = $storage
        ->loadParents($entity
        ->id());
      $parent = reset($parents);
      if ($parent instanceof TermInterface) {
        $entity->parent->target_id = $parent
          ->id();
      }
      else {
        $entity->parent->target_id = 0;
      }
    }
    return parent::normalize($entity, $format, $context);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableNormalizerInterface::SERIALIZATION_CONTEXT_CACHEABILITY constant Name of key for bubbling cacheability metadata via serialization context.
ContentEntityNormalizer::$dispatcher protected property
ContentEntityNormalizer::$indexFactory protected property
ContentEntityNormalizer::$languageManager protected property
ContentEntityNormalizer::$moduleHandler private property
ContentEntityNormalizer::$selectionManager protected property
ContentEntityNormalizer::$usersMapping protected property
ContentEntityNormalizer::createEntityInstance private function Handles entity creation for fieldable and non-fieldable entities.
ContentEntityNormalizer::denormalize public function Denormalizes data back into an object of the given class. 2
ContentEntityNormalizer::denormalizeMenuLinkParent protected function
ContentEntityNormalizer::denormalizeTranslation private function
ContentEntityNormalizer::__construct public function 1
FieldableEntityNormalizerTrait::$entityFieldManager protected property The entity field manager.
FieldableEntityNormalizerTrait::$entityTypeManager protected property The entity type manager. 1
FieldableEntityNormalizerTrait::$entityTypeRepository protected property The entity type repository.
FieldableEntityNormalizerTrait::constructValue protected function Build the field item value using the incoming data. 7
FieldableEntityNormalizerTrait::denormalizeFieldData protected function Denormalizes entity data by denormalizing each field individually.
FieldableEntityNormalizerTrait::determineEntityTypeId protected function Determines the entity type ID to denormalize as.
FieldableEntityNormalizerTrait::extractBundleData protected function Denormalizes the bundle property so entity creation can use it.
FieldableEntityNormalizerTrait::getEntityFieldManager protected function Returns the entity field manager.
FieldableEntityNormalizerTrait::getEntityTypeDefinition protected function Gets the entity type definition.
FieldableEntityNormalizerTrait::getEntityTypeManager protected function Returns the entity type manager.
FieldableEntityNormalizerTrait::getEntityTypeRepository protected function Returns the entity type repository.
NormalizerBase::$format protected property List of formats which supports (de-)normalization. 3
NormalizerBase::addCacheableDependency protected function Adds cacheability if applicable.
NormalizerBase::checkFormat protected function Checks if the provided format is supported by this normalizer. 2
NormalizerBase::supportsDenormalization public function Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() 1
NormalizerBase::supportsNormalization public function Checks whether the given class is supported for normalization by this normalizer. 1
TaxonomyTermNormalizer::$supportedInterfaceOrClass protected property Overrides ContentEntityNormalizer::$supportedInterfaceOrClass
TaxonomyTermNormalizer::normalize public function Normalizes an object into a set of arrays/scalars. Overrides ContentEntityNormalizer::normalize