3 namespace Drupal\serialization\Normalizer;
6 * Normalizes/denormalizes Drupal config entity objects into an array structure.
8 class ConfigEntityNormalizer extends EntityNormalizer {
11 * The interface or class that this Normalizer supports.
15 protected $supportedInterfaceOrClass = ['Drupal\Core\Config\Entity\ConfigEntityInterface'];
20 public function normalize($object, $format = NULL, array $context = []) {
21 return static::getDataWithoutInternals($object->toArray());
27 public function denormalize($data, $class, $format = NULL, array $context = []) {
28 return parent::denormalize(static::getDataWithoutInternals($data), $class, $format, $context);
32 * Gets the given data without the internal implementation details.
35 * The data that is either currently or about to be stored in configuration.
38 * The same data, but without internals. Currently, that is only the '_core'
39 * key, which is reserved by Drupal core to handle complex edge cases
40 * correctly. Data in the '_core' key is irrelevant to clients reading
41 * configuration, and is not allowed to be set by clients writing
42 * configuration: it is for Drupal core only, and managed by Drupal core.
44 * @see https://www.drupal.org/node/2653358
46 protected static function getDataWithoutInternals(array $data) {
47 return array_diff_key($data, ['_core' => TRUE]);