diff -u b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php --- b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -243,8 +243,14 @@ public function toArray() { $properties = array(); try { + $id_key = $this->getEntityType()->getKey('id'); foreach ($this->getPropertiesFromSchema() as $name) { - $properties[$name] = $this->get($name); + if ($name == $id_key) { + $properties[$name] = $this->id(); + } + else { + $properties[$name] = $this->get($name); + } } } catch (SchemaIncompleteException $e) { only in patch2: unchanged: --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php @@ -214,29 +214,6 @@ public function getBreakpointById($id) { /** * {@inheritdoc} */ - public function toArray() { - $names = array( - 'id', - 'uuid', - 'name', - 'label', - 'breakpoint_ids', - 'source', - 'sourceType', - 'status', - 'langcode', - 'dependencies', - ); - $properties = array(); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - return $properties; - } - - /** - * {@inheritdoc} - */ public function calculateDependencies() { parent::calculateDependencies(); only in patch2: unchanged: --- a/core/modules/editor/lib/Drupal/editor/Entity/Editor.php +++ b/core/modules/editor/lib/Drupal/editor/Entity/Editor.php @@ -162,21 +162,4 @@ public function setImageUploadSettings(array $image_upload_settings) { return $this; } - /** - * {@inheritdoc} - */ - public function toArray() { - $properties = parent::toArray(); - $names = array( - 'format', - 'editor', - 'settings', - 'image_upload', - ); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - return $properties; - } - } only in patch2: unchanged: --- a/core/modules/entity/config/schema/entity.schema.yml +++ b/core/modules/entity/config/schema/entity.schema.yml @@ -116,14 +116,20 @@ entity.form_display.*.*.*: mode: type: string label: 'View or form mode machine name' + status: + type: boolean + label: 'Enabled' content: type: sequence - label: 'Field form display formatters' + label: 'Field display formatters' sequence: - type: entity_form_display.field.[type] - status: - type: boolean - label: 'Enabled' + hidden: + type: sequence + label: 'Field display setting' + sequence: + - type: boolean + label: 'Value' dependencies: type: config_dependencies label: 'Dependencies' only in patch2: unchanged: --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -201,23 +201,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { * {@inheritdoc} */ public function toArray() { - $names = array( - 'uuid', - 'targetEntityType', - 'bundle', - 'mode', - 'content', - 'hidden', - 'status', - 'dependencies' - ); - $properties = array( - 'id' => $this->id(), - ); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - + $properties = parent::toArray(); // Do not store options for fields whose display is not set to be // configurable. foreach ($this->getFieldDefinitions() as $field_name => $definition) { only in patch2: unchanged: --- a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php @@ -226,34 +226,6 @@ public function id() { } /** - * {@inheritdoc} - */ - public function toArray() { - $names = array( - 'uuid', - 'status', - 'langcode', - 'name', - 'entity_type', - 'type', - 'settings', - 'module', - 'locked', - 'cardinality', - 'translatable', - 'indexes', - 'dependencies', - ); - $properties = array( - 'id' => $this->id(), - ); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - return $properties; - } - - /** * Overrides \Drupal\Core\Entity\Entity::preSave(). * * @throws \Drupal\field\FieldException @@ -725,7 +697,10 @@ public function entityCount($as_bool = FALSE) { */ public function __sleep() { // Only serialize properties from self::toArray(). - return array_keys(array_intersect_key($this->toArray(), get_object_vars($this))); + $properties = array_keys(array_intersect_key($this->toArray(), get_object_vars($this))); + // Serialize $entityTypeId property so that toArray() works when waking up. + $properties[] = 'entityTypeId'; + return $properties; } /** only in patch2: unchanged: --- a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php @@ -291,29 +291,7 @@ public function id() { * {@inheritdoc} */ public function toArray() { - $names = array( - 'uuid', - 'status', - 'langcode', - 'field_uuid', - 'field_name', - 'entity_type', - 'bundle', - 'label', - 'description', - 'required', - 'default_value', - 'default_value_function', - 'settings', - 'dependencies', - ); - $properties = array( - 'id' => $this->id(), - ); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - + $properties = parent::toArray(); // Additionally, include the field type, that is needed to be able to // generate the field-type-dependant parts of the config schema. if (isset($this->field->type)) { @@ -662,7 +640,10 @@ public function targetBundle() { */ public function __sleep() { // Only serialize properties from self::toArray(). - return array_keys(array_intersect_key($this->toArray(), get_object_vars($this))); + $properties = array_keys(array_intersect_key($this->toArray(), get_object_vars($this))); + // Serialize $entityTypeId property so that toArray() works when waking up. + $properties[] = 'entityTypeId'; + return $properties; } /** only in patch2: unchanged: --- a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php @@ -363,20 +363,6 @@ public function saveImageEffect(array $configuration) { /** * {@inheritdoc} */ - public function toArray() { - $properties = parent::toArray(); - $names = array( - 'effects', - ); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - return $properties; - } - - /** - * {@inheritdoc} - */ public function getReplacementID() { return $this->get('replacementID'); } only in patch2: unchanged: --- a/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php +++ b/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php @@ -136,30 +136,6 @@ public function id() { /** * {@inheritdoc} */ - public function toArray() { - $names = array( - 'uuid', - 'targetEntityType', - 'bundle', - 'types', - 'fieldMappings', - ); - $properties = array( - 'id' => $this->id(), - ); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - if (!empty($this->dependencies)) { - // Add protected dependencies property if set. - $properties['dependencies'] = $this->dependencies; - } - return $properties; - } - - /** - * {@inheritdoc} - */ public function calculateDependencies() { parent::calculateDependencies(); $entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); only in patch2: unchanged: --- a/core/modules/responsive_image/lib/Drupal/responsive_image/Entity/ResponsiveImageMapping.php +++ b/core/modules/responsive_image/lib/Drupal/responsive_image/Entity/ResponsiveImageMapping.php @@ -189,24 +189,6 @@ public function hasMappings() { /** * {@inheritdoc} */ - public function toArray() { - $names = array( - 'id', - 'uuid', - 'label', - 'mappings', - 'breakpointGroup', - ); - $properties = array(); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - return $properties; - } - - /** - * {@inheritdoc} - */ public function setMappings(array $mappings) { $this->set('mappings', $mappings); return $this; only in patch2: unchanged: --- a/core/modules/search/lib/Drupal/search/Entity/SearchPage.php +++ b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php @@ -164,23 +164,6 @@ public function getWeight() { /** * {@inheritdoc} */ - public function toArray() { - $properties = parent::toArray(); - $names = array( - 'path', - 'weight', - 'plugin', - 'configuration', - ); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - return $properties; - } - - /** - * {@inheritdoc} - */ public function postCreate(EntityStorageInterface $storage) { parent::postCreate($storage); only in patch2: unchanged: --- a/core/modules/system/lib/Drupal/system/Entity/Action.php +++ b/core/modules/system/lib/Drupal/system/Entity/Action.php @@ -143,20 +143,4 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) return parent::sort($a, $b); } - /** - * {@inheritdoc} - */ - public function toArray() { - $properties = parent::toArray(); - $names = array( - 'type', - 'plugin', - 'configuration', - ); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - return $properties; - } - } only in patch2: unchanged: --- a/core/modules/system/lib/Drupal/system/Entity/Menu.php +++ b/core/modules/system/lib/Drupal/system/Entity/Menu.php @@ -60,22 +60,6 @@ class Menu extends ConfigEntityBase implements MenuInterface { /** * {@inheritdoc} */ - public function toArray() { - $properties = parent::toArray(); - // @todo Make $description protected and include it here, see - // https://drupal.org/node/2030645. - $names = array( - 'locked', - ); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - return $properties; - } - - /** - * {@inheritdoc} - */ public function isLocked() { return (bool) $this->locked; } only in patch2: unchanged: --- a/core/modules/tour/lib/Drupal/tour/Entity/Tour.php +++ b/core/modules/tour/lib/Drupal/tour/Entity/Tour.php @@ -123,21 +123,6 @@ public function getTips() { /** * {@inheritdoc} */ - public function toArray() { - $properties = parent::toArray(); - $names = array( - 'routes', - 'tips', - ); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - return $properties; - } - - /** - * {@inheritdoc} - */ public function hasMatchingRoute($route_name, $route_params) { if (!isset($this->keyedRoutes)) { $this->keyedRoutes = array(); only in patch2: unchanged: --- a/core/modules/views/lib/Drupal/views/Entity/View.php +++ b/core/modules/views/lib/Drupal/views/Entity/View.php @@ -241,32 +241,6 @@ public function &getDisplay($display_id) { /** * {@inheritdoc} */ - public function toArray() { - $names = array( - 'base_field', - 'base_table', - 'core', - 'description', - 'status', - 'display', - 'label', - 'module', - 'id', - 'tag', - 'uuid', - 'langcode', - 'dependencies', - ); - $properties = array(); - foreach ($names as $name) { - $properties[$name] = $this->get($name); - } - return $properties; - } - - /** - * {@inheritdoc} - */ public function calculateDependencies() { parent::calculateDependencies();