Skip to content

Commit

Permalink
Distinguish apigee baseFields during __get (apigee#948)
Browse files Browse the repository at this point in the history
  • Loading branch information
boobaa committed Oct 11, 2023
1 parent b9ba6d0 commit a15bae1
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Entity/FieldableEdgeEntityBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit a15bae1

Please sign in to comment.