X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fserialization%2Fsrc%2FNormalizer%2FConfigEntityNormalizer.php;h=f6332a36faf0bc9e3d8efb773932c9f3d357c784;hp=344bcc3387be23e32a1bc2c26c56ba1fd1f81177;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/modules/serialization/src/Normalizer/ConfigEntityNormalizer.php b/web/core/modules/serialization/src/Normalizer/ConfigEntityNormalizer.php index 344bcc338..f6332a36f 100644 --- a/web/core/modules/serialization/src/Normalizer/ConfigEntityNormalizer.php +++ b/web/core/modules/serialization/src/Normalizer/ConfigEntityNormalizer.php @@ -18,7 +18,33 @@ class ConfigEntityNormalizer extends EntityNormalizer { * {@inheritdoc} */ public function normalize($object, $format = NULL, array $context = []) { - return $object->toArray(); + return static::getDataWithoutInternals($object->toArray()); + } + + /** + * {@inheritdoc} + */ + public function denormalize($data, $class, $format = NULL, array $context = []) { + return parent::denormalize(static::getDataWithoutInternals($data), $class, $format, $context); + } + + /** + * Gets the given data without the internal implementation details. + * + * @param array $data + * The data that is either currently or about to be stored in configuration. + * + * @return array + * The same data, but without internals. Currently, that is only the '_core' + * key, which is reserved by Drupal core to handle complex edge cases + * correctly. Data in the '_core' key is irrelevant to clients reading + * configuration, and is not allowed to be set by clients writing + * configuration: it is for Drupal core only, and managed by Drupal core. + * + * @see https://www.drupal.org/node/2653358 + */ + protected static function getDataWithoutInternals(array $data) { + return array_diff_key($data, ['_core' => TRUE]); } }