You are here

protected static function CacheableNormalization::hasNoNestedInstances in Drupal 9

Same name and namespace in other branches
  1. 8 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()

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;
}