From 001dcd23236055f9714fb760a0a4483d394bcf45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?CS=C3=89CSY=20L=C3=A1szl=C3=B3?= Date: Wed, 11 Oct 2023 19:44:50 +0200 Subject: [PATCH] Distinguish apigee baseFields during __get (#948) --- src/Entity/FieldableEdgeEntityBase.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Entity/FieldableEdgeEntityBase.php b/src/Entity/FieldableEdgeEntityBase.php index eb780121..0a0a391a 100644 --- a/src/Entity/FieldableEdgeEntityBase.php +++ b/src/Entity/FieldableEdgeEntityBase.php @@ -569,8 +569,7 @@ public function &__get($name) { if (!isset($this->fieldDefinitions)) { $this->getFieldDefinitions(); } - // Apigee base fields are special, so they need special treatment. - if (isset($this->fieldDefinitions[$name]) && !($this->fieldDefinitions[$name] instanceof BaseFieldDefinition)) { + if (isset($this->fieldDefinitions[$name])) { $return = $this->getField($name); return $return; } @@ -607,6 +606,11 @@ public function __set($name, $value) { $this->getField($name)->setValue($value); } } + // The translations array is unset when cloning the entity object, we just + // need to restore it. + elseif ($name == 'translations') { + $this->translations = $value; + } // Directly write non-field values. else { $this->values[$name] = $value; @@ -636,6 +640,17 @@ public function __unset($name) { } } + /** + * An array of entity translation metadata. + * + * An associative array keyed by translation language code. Every value is an + * array containing the translation status and the translation object, if it has + * already been instantiated. + * + * @var array + */ + private $translations = []; + /** * Gets a non-translatable field. *