Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AbstractObjectNormalizer.php

function AbstractObjectNormalizer::getAttributes

Gets and caches attributes for the given object, format and context.

Return value

string[]

1 call to AbstractObjectNormalizer::getAttributes()
AbstractObjectNormalizer::normalize in vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php
Normalizes data into a set of arrays/scalars.

File

vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php, line 251

Class

AbstractObjectNormalizer
Base class for a normalizer dealing with objects.

Namespace

Symfony\Component\Serializer\Normalizer

Code

protected function getAttributes(object $object, ?string $format, array $context) : array {
    $class = ($this->objectClassResolver)($object);
    $key = $class . '-' . $context['cache_key'];
    if (isset($this->attributesCache[$key])) {
        return $this->attributesCache[$key];
    }
    $allowedAttributes = $this->getAllowedAttributes($object, $context, true);
    if (false !== $allowedAttributes) {
        if ($context['cache_key']) {
            $this->attributesCache[$key] = $allowedAttributes;
        }
        return $allowedAttributes;
    }
    $attributes = $this->extractAttributes($object, $format, $context);
    if ($mapping = $this->classDiscriminatorResolver?->getMappingForMappedObject($object)) {
        array_unshift($attributes, $mapping->getTypeProperty());
    }
    if ($context['cache_key'] && \stdClass::class !== $class) {
        $this->attributesCache[$key] = $attributes;
    }
    return $attributes;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal