function CacheableNormalization::hasNoNestedInstances

Same name in other branches
  1. 8.9.x core/modules/jsonapi/src/Normalizer/Value/CacheableNormalization.php \Drupal\jsonapi\Normalizer\Value\CacheableNormalization::hasNoNestedInstances()
  2. 10 core/modules/jsonapi/src/Normalizer/Value/CacheableNormalization.php \Drupal\jsonapi\Normalizer\Value\CacheableNormalization::hasNoNestedInstances()
  3. 11.x core/modules/jsonapi/src/Normalizer/Value/CacheableNormalization.php \Drupal\jsonapi\Normalizer\Value\CacheableNormalization::hasNoNestedInstances()

Ensures that no nested values are instances of this class.

Parameters

array|\Traversable $array: The traversable object which may contain instance of this object.

Return value

bool Whether the given object or its children have CacheableNormalizations in them.

1 call to CacheableNormalization::hasNoNestedInstances()
CacheableNormalization::__construct in core/modules/jsonapi/src/Normalizer/Value/CacheableNormalization.php
CacheableNormalization constructor.

File

core/modules/jsonapi/src/Normalizer/Value/CacheableNormalization.php, line 131

Class

CacheableNormalization
Use to store normalized data and its cacheability.

Namespace

Drupal\jsonapi\Normalizer\Value

Code

protected static function hasNoNestedInstances($array) {
    foreach ($array as $value) {
        if ((is_array($value) || $value instanceof \Traversable) && !static::hasNoNestedInstances($value) || $value instanceof static) {
            return FALSE;
        }
    }
    return TRUE;
}

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