public function JsonldEntityWrapper::getProperties

Get properties, excluding JSON-LD specific properties.

Return value

array An array of properties structured as in JSON-LD.

File

drupal/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php, line 71
Definition of Drupal\jsonld\JsonldEntityWrapper.

Class

JsonldEntityWrapper
Provide an interface for JsonldNormalizer to get required properties.

Namespace

Drupal\jsonld

Code

public function getProperties() {

  // Properties to skip.
  $skip = array(
    'id',
  );

  // Create language map property structure.
  foreach ($this->entity
    ->getTranslationLanguages() as $langcode => $language) {
    foreach ($this->entity
      ->getTranslation($langcode) as $name => $field) {
      $definition = $this->entity
        ->getPropertyDefinition($name);
      $langKey = empty($definition['translatable']) ? LANGUAGE_NOT_SPECIFIED : $langcode;
      if (!$field
        ->isEmpty()) {
        $properties[$name][$langKey] = $this->serializer
          ->normalize($field, $this->format);
      }
    }
  }

  // Only return properties which are not in the $skip array.
  return array_diff_key($properties, array_fill_keys($skip, ''));
}