ConfigEntityDenormalizer.php

Same filename in other branches
  1. 8.9.x core/modules/jsonapi/src/Normalizer/ConfigEntityDenormalizer.php
  2. 10 core/modules/jsonapi/src/Normalizer/ConfigEntityDenormalizer.php
  3. 11.x core/modules/jsonapi/src/Normalizer/ConfigEntityDenormalizer.php

Namespace

Drupal\jsonapi\Normalizer

File

core/modules/jsonapi/src/Normalizer/ConfigEntityDenormalizer.php

View source
<?php

namespace Drupal\jsonapi\Normalizer;

use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\jsonapi\ResourceType\ResourceType;

/**
 * Converts the Drupal config entity object to a JSON:API array structure.
 *
 * @internal JSON:API maintains no PHP API since its API is the HTTP API. This
 *   class may change at any time and this will break any dependencies on it.
 *
 * @see https://www.drupal.org/project/drupal/issues/3032787
 * @see jsonapi.api.php
 */
final class ConfigEntityDenormalizer extends EntityDenormalizerBase {
    
    /**
     * {@inheritdoc}
     */
    protected $supportedInterfaceOrClass = ConfigEntityInterface::class;
    
    /**
     * {@inheritdoc}
     */
    protected function prepareInput(array $data, ResourceType $resource_type, $format, array $context) {
        $prepared = [];
        foreach ($data as $key => $value) {
            $prepared[$resource_type->getInternalName($key)] = $value;
        }
        return $prepared;
    }
    
    /**
     * {@inheritdoc}
     */
    public function hasCacheableSupportsMethod() : bool {
        return TRUE;
    }

}

Classes

Title Deprecated Summary
ConfigEntityDenormalizer Converts the Drupal config entity object to a JSON:API array structure.

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