You are here

class ContentEntityNormalizer in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/hal/src/Normalizer/ContentEntityNormalizer.php \Drupal\hal\Normalizer\ContentEntityNormalizer
  2. 8 core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php \Drupal\serialization\Normalizer\ContentEntityNormalizer
Same name and namespace in other branches
  1. 8.0 core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php \Drupal\serialization\Normalizer\ContentEntityNormalizer

Normalizes/denormalizes Drupal content entities into an array structure.

Hierarchy

Expanded class hierarchy of ContentEntityNormalizer

1 file declares its use of ContentEntityNormalizer
ContentEntityNormalizerTest.php in core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php
Contains \Drupal\Tests\serialization\Unit\Normalizer\ContentEntityNormalizerTest.
1 string reference to 'ContentEntityNormalizer'
serialization.services.yml in core/modules/serialization/serialization.services.yml
core/modules/serialization/serialization.services.yml
1 service uses ContentEntityNormalizer
serializer.normalizer.content_entity in core/modules/serialization/serialization.services.yml
Drupal\serialization\Normalizer\ContentEntityNormalizer

File

core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php, line 13
Contains \Drupal\serialization\Normalizer\ContentEntityNormalizer.

Namespace

Drupal\serialization\Normalizer
View source
class ContentEntityNormalizer extends EntityNormalizer {

  /**
   * The interface or class that this Normalizer supports.
   *
   * @var array
   */
  protected $supportedInterfaceOrClass = [
    'Drupal\\Core\\Entity\\ContentEntityInterface',
  ];

  /**
   * {@inheritdoc}
   */
  public function normalize($object, $format = NULL, array $context = array()) {
    $context += array(
      'account' => NULL,
    );
    $attributes = [];
    foreach ($object as $name => $field) {
      if ($field
        ->access('view', $context['account'])) {
        $attributes[$name] = $this->serializer
          ->normalize($field, $format, $context);
      }
    }
    return $attributes;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentEntityNormalizer::$supportedInterfaceOrClass protected property The interface or class that this Normalizer supports. Overrides EntityNormalizer::$supportedInterfaceOrClass
ContentEntityNormalizer::normalize public function Normalizes an object into a set of arrays/scalars. Overrides ComplexDataNormalizer::normalize
EntityNormalizer::$entityManager protected property The entity manager.
EntityNormalizer::denormalize public function Denormalizes data back into an object of the given class. Overrides DenormalizerInterface::denormalize
EntityNormalizer::__construct public function Constructs an EntityNormalizer object.
NormalizerBase::checkFormat protected function Checks if the provided format is supported by this normalizer.
NormalizerBase::supportsDenormalization public function Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() 1
NormalizerBase::supportsNormalization public function Checks whether the given class is supported for normalization by this normalizer. Overrides NormalizerInterface::supportsNormalization 1
SerializerAwareNormalizer::$serializer protected property
SerializerAwareNormalizer::setSerializer public function Sets the owning Serializer object. Overrides SerializerAwareInterface::setSerializer