You are here

class ConfigEntityDenormalizer in JSON:API Extras 8.3

Override ConfigEntityNormalizer to prepare input.

Hierarchy

  • class \Drupal\jsonapi_extras\Normalizer\JsonApiNormalizerDecoratorBase implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface, \Symfony\Component\Serializer\Normalizer\DenormalizerInterface, \Symfony\Component\Serializer\SerializerAwareInterface

Expanded class hierarchy of ConfigEntityDenormalizer

1 file declares its use of ConfigEntityDenormalizer
ConfigEntityDenormalizerImpostor.php in src-impostor-normalizers/ConfigEntityDenormalizerImpostor.php

File

src/Normalizer/ConfigEntityDenormalizer.php, line 10

Namespace

Drupal\jsonapi_extras\Normalizer
View source
class ConfigEntityDenormalizer extends JsonApiNormalizerDecoratorBase {

  /**
   * {@inheritdoc}
   */
  public function denormalize($data, $class, $format = NULL, array $context = []) {
    return parent::denormalize($this
      ->prepareInput($data, $context['resource_type']), $class, $format, $context);
  }

  /**
   * {@inheritdoc}
   */
  protected function prepareInput(array $data, ResourceType $resource_type) {
    foreach ($data as $public_field_name => &$field_value) {

      /** @var \Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerInterface $enhancer */
      $enhancer = $resource_type
        ->getFieldEnhancer($public_field_name);
      if (!$enhancer) {
        continue;
      }
      $field_value = $enhancer
        ->transform($field_value);
    }
    return $data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigEntityDenormalizer::denormalize public function Denormalizes data back into an object of the given class. Overrides JsonApiNormalizerDecoratorBase::denormalize
ConfigEntityDenormalizer::prepareInput protected function
JsonApiNormalizerDecoratorBase::$inner protected property The decorated (de)normalizer.
JsonApiNormalizerDecoratorBase::normalize public function Normalizes an object into a set of arrays/scalars. 3
JsonApiNormalizerDecoratorBase::setSerializer public function Sets the owning Serializer object.
JsonApiNormalizerDecoratorBase::supportsDenormalization public function Checks whether the given class is supported for denormalization by this normalizer.
JsonApiNormalizerDecoratorBase::supportsNormalization public function Checks whether the given class is supported for normalization by this normalizer.
JsonApiNormalizerDecoratorBase::__construct public function JsonApiNormalizerDecoratorBase constructor. 2