Commit 4a7c9ca7 authored by George's avatar George
Browse files

Issue #3160617 by _KASH_: FieldItemListNormalizer does not check access for entities in the list.

parent 91bdae78
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\entity_normalization\Normalizer;

use Drupal\Core\Access\AccessibleInterface;
use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\entity_normalization\FieldConfigInterface;
@@ -87,6 +88,12 @@ class FieldItemListNormalizer extends NormalizerBase implements ContextAwareNorm
    }

    foreach ($list as $entity) {
      if ($entity instanceof AccessibleInterface && !$entity->access('view')) {
        if ($cardinality === 1) {
          $result = NULL;
        }
        continue;
      }
      if ($normalizer !== NULL && $normalizer->supportsNormalization($entity, $format, $context)) {
        $normalizedValue = $normalizer->normalize($entity, $format, $context);
      }