public function JsonldEntityNormalizer::normalize

Implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize()

Overrides NormalizerInterface::normalize

File

drupal/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php, line 22
Definition of Drupal\jsonld\JsonldEntityNormalizer.

Class

JsonldEntityNormalizer
Converts the Drupal entity object structure to JSON-LD array structure.

Namespace

Drupal\jsonld

Code

public function normalize($entity, $format = NULL) {
  $entityWrapper = new JsonldEntityWrapper($entity, $format, $this->serializer);
  $attributes = $entityWrapper
    ->getProperties();
  $attributes = array(
    '@id' => $entityWrapper
      ->getId(),
  ) + $attributes;
  return $attributes;
}