You are here

class ComplexDataNormalizer in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php \Drupal\serialization\Normalizer\ComplexDataNormalizer

Converts the Drupal entity object structures to a normalized array.

This is the default Normalizer for entities. All formats that have Encoders registered with the Serializer in the DIC will be normalized with this class unless another Normalizer is registered which supersedes it. If a module wants to use format-specific or class-specific normalization, then that module can register a new Normalizer and give it a higher priority than this one.

Hierarchy

Expanded class hierarchy of ComplexDataNormalizer

1 file declares its use of ComplexDataNormalizer
ComplexDataNormalizerTest.php in core/modules/serialization/tests/src/Unit/Normalizer/ComplexDataNormalizerTest.php
Contains \Drupal\Tests\serialization\Unit\Normalizer\ComplexDataNormalizerTest.
1 string reference to 'ComplexDataNormalizer'
serialization.services.yml in core/modules/serialization/serialization.services.yml
core/modules/serialization/serialization.services.yml
1 service uses ComplexDataNormalizer
serializer.normalizer.complex_data in core/modules/serialization/serialization.services.yml
Drupal\serialization\Normalizer\ComplexDataNormalizer

File

core/modules/serialization/src/Normalizer/ComplexDataNormalizer.php, line 20
Contains \Drupal\serialization\Normalizer\ComplexDataNormalizer.

Namespace

Drupal\serialization\Normalizer
View source
class ComplexDataNormalizer extends NormalizerBase {

  /**
   * The interface or class that this Normalizer supports.
   *
   * @var string
   */
  protected $supportedInterfaceOrClass = 'Drupal\\Core\\TypedData\\ComplexDataInterface';

  /**
   * {@inheritdoc}
   */
  public function normalize($object, $format = NULL, array $context = array()) {
    $attributes = array();
    foreach ($object as $name => $field) {
      $attributes[$name] = $this->serializer
        ->normalize($field, $format, $context);
    }
    return $attributes;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ComplexDataNormalizer::$supportedInterfaceOrClass protected property The interface or class that this Normalizer supports. Overrides NormalizerBase::$supportedInterfaceOrClass 2
ComplexDataNormalizer::normalize public function Normalizes an object into a set of arrays/scalars. Overrides NormalizerInterface::normalize 3
NormalizerBase::checkFormat protected function Checks if the provided format is supported by this normalizer.
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. Overrides NormalizerInterface::supportsNormalization 1
SerializerAwareNormalizer::$serializer protected property
SerializerAwareNormalizer::setSerializer public function Sets the owning Serializer object. Overrides SerializerAwareInterface::setSerializer