From 78594ab63cc10c06c6c8acb87196c4d4e45bbef8 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Wed, 14 May 2014 17:44:50 -0500 Subject: [PATCH] Issue #2229181 by pwolanin, Berdir, fago: MapItem::propertyDefinitions() claims it has a static value property, which is wrong. --- .../Core/Field/Plugin/Field/FieldType/MapItem.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php index 26cdc41c6061..4645b833a7b0 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php @@ -27,10 +27,8 @@ class MapItem extends FieldItemBase { * {@inheritdoc} */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { - $properties['value'] = DataDefinition::create('string') - ->setLabel(t('Serialized values')); - - return $properties; + // The properties are dynamic and can not be defined statically. + return array(); } /** @@ -48,6 +46,15 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) ); } + /** + * {@inheritdoc} + */ + public function toArray() { + // The default implementation of toArray() only returns known properties. + // For a map, return everything as the properties are not pre-defined. + return $this->getValue(); + } + /** * {@inheritdoc} */ -- GitLab