diff --git a/core/modules/jsonld/lib/Drupal/jsonld/DrupalJsonldEntityWrapper.php b/core/modules/jsonld/lib/Drupal/jsonld/DrupalJsonldEntityWrapper.php index e9cf804..0bdd07e 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/DrupalJsonldEntityWrapper.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/DrupalJsonldEntityWrapper.php @@ -23,34 +23,13 @@ public function getProperties() { // Properties to skip. $skip = array('id'); - // Get default language. - if ($this->entity->language()->langcode !== 'und') { - $defaultLangcode = $this->entity->language()->langcode; - } - else { - $language = variable_get('language_default'); - $defaultLangcode = $language['langcode']; - } - - // Process all the field values from the default language. - foreach ($this->entity as $name => $field) { - $definition = $this->entity->getPropertyDefinition($name); - // Add non-translatable values, keyed by langcode 'und'. - if (empty($definition['translatable'])) { - $properties[$name]['und'] = $field->getValue(); - } - // Add translatable values, keyed by the default langcode. - else { - $properties[$name][$defaultLangcode] = $field->getValue(); - } - } - // Add in values from translations. - foreach ($this->entity->getTranslationLanguages(FALSE) as $langcode => $language) { + // Create language map property structure. + foreach ($this->entity->getTranslationLanguages() as $langcode => $language) { foreach ($this->entity->getTranslation($langcode) as $name => $field) { - // Ensure that there is a value set for the field in this translation - // before adding an array element for it. + $definition = $this->entity->getPropertyDefinition($name); + $langKey = empty($definition['translatable']) ? 'und' : $langcode; if (!$field->isEmpty()) { - $properties[$name][$langcode] = $field->getValue(); + $properties[$name][$langKey] = $field->getValue(); } } } diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizer.php index 6bd6db9..61c654a 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizer.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldNormalizer.php @@ -7,6 +7,7 @@ namespace Drupal\jsonld; +use Drupal\Core\Entity\EntityNG; use Symfony\Component\Serializer\Exception\RuntimeException; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; @@ -62,7 +63,7 @@ public function normalize($object, $format = NULL) { */ public function supportsNormalization($data, $format = NULL) { // If this is an Entity object and the request is for JSON-LD. - return is_object($data) && is_subclass_of($data, 'Drupal\Core\Entity\EntityNG') && static::$format === $format; + return is_object($data) && ($data instanceof EntityNG) && static::$format === $format; } }