You are here

public function FieldableEdgeEntityBase::onChange in Apigee Edge 8

Reacts to changes to a field.

Note that this is invoked after any changes have been applied.

Parameters

string $field_name: The name of the field which is changed.

Throws

\InvalidArgumentException When trying to assign a value to the language field that matches an existing translation.

\LogicException When trying to change:

  • The language of a translation.
  • The value of the flag identifying the default translation object.

Overrides FieldableEntityInterface::onChange

File

src/Entity/FieldableEdgeEntityBase.php, line 386

Class

FieldableEdgeEntityBase
Base field support for Apigee Entities without making them content entities.

Namespace

Drupal\apigee_edge\Entity

Code

public function onChange($field_name) {
  $value = $this
    ->convertFieldValueToPropertyValue($field_name);

  // Save field's value to the its related property (if there is one).
  try {
    $this
      ->setPropertyValue($field_name, $value);
  } catch (InvalidArgumentException $e) {

    // Property not found, which could be fine.
  }
}