NullNormalizer.php

Same filename in other branches
  1. 9 core/modules/serialization/src/Normalizer/NullNormalizer.php
  2. 8.9.x core/modules/serialization/src/Normalizer/NullNormalizer.php
  3. 11.x core/modules/serialization/src/Normalizer/NullNormalizer.php

Namespace

Drupal\serialization\Normalizer

File

core/modules/serialization/src/Normalizer/NullNormalizer.php

View source
<?php

namespace Drupal\serialization\Normalizer;


/**
 * Null normalizer.
 */
class NullNormalizer extends NormalizerBase {
    
    /**
     * The interface or class that this Normalizer supports.
     *
     * @var string[]
     */
    protected array $supportedTypes = [
        '*' => FALSE,
    ];
    
    /**
     * Constructs a NullNormalizer object.
     *
     * @param string|array $supported_interface_of_class
     *   The supported interface(s) or class(es).
     */
    public function __construct($supported_interface_of_class) {
        $this->supportedTypes = [
            $supported_interface_of_class => TRUE,
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    public function normalize($object, $format = NULL, array $context = []) : array|string|int|float|bool|\ArrayObject|null {
        return NULL;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getSupportedTypes(?string $format) : array {
        return $this->supportedTypes;
    }

}

Classes

Title Deprecated Summary
NullNormalizer Null normalizer.

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