function XmlEntityNormalizationQuirksTrait::applyXmlConfigEntityDecodingQuirks

Same name in other branches
  1. 9 core/modules/rest/tests/src/Functional/EntityResource/XmlEntityNormalizationQuirksTrait.php \Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait::applyXmlConfigEntityDecodingQuirks()
  2. 10 core/modules/rest/tests/src/Functional/EntityResource/XmlEntityNormalizationQuirksTrait.php \Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait::applyXmlConfigEntityDecodingQuirks()
  3. 11.x core/modules/rest/tests/src/Functional/EntityResource/XmlEntityNormalizationQuirksTrait.php \Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait::applyXmlConfigEntityDecodingQuirks()

Applies the XML config entity encoding quirks that remain after decoding.

The XML encoding:

  • loses type data (int and bool become string)
  • converts single-item arrays into single items (non-arrays)

Parameters

array $normalization: An entity normalization.

Return value

array The updated config entity normalization.

See also

\Symfony\Component\Serializer\Encoder\XmlEncoder

1 call to XmlEntityNormalizationQuirksTrait::applyXmlConfigEntityDecodingQuirks()
XmlEntityNormalizationQuirksTrait::getExpectedNormalizedEntity in core/modules/rest/tests/src/Functional/EntityResource/XmlEntityNormalizationQuirksTrait.php

File

core/modules/rest/tests/src/Functional/EntityResource/XmlEntityNormalizationQuirksTrait.php, line 134

Class

XmlEntityNormalizationQuirksTrait
Trait for EntityResourceTestBase subclasses testing $format='xml'.

Namespace

Drupal\Tests\rest\Functional\EntityResource

Code

protected function applyXmlConfigEntityDecodingQuirks(array $normalization) {
    $normalization = static::castToString($normalization);
    // When a single dependency is listed, it's not decoded into an array.
    if (isset($normalization['dependencies'])) {
        foreach ($normalization['dependencies'] as $dependency_type => $dependency_list) {
            if (count($dependency_list) === 1) {
                $normalization['dependencies'][$dependency_type] = $dependency_list[0];
            }
        }
    }
    return $normalization;
}

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