You are here

public function LanguageItem::onChange in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php \Drupal\Core\Field\Plugin\Field\FieldType\LanguageItem::onChange()
  2. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php \Drupal\Core\Field\Plugin\Field\FieldType\LanguageItem::onChange()

Parameters

$property_name: The name of the property.

bool $notify: (optional) Whether to forward the notification to the parent. Defaults to TRUE. By passing FALSE, overrides of this method can re-use the logic of parent classes without triggering notification.

Overrides Map::onChange

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php, line 98

Class

LanguageItem
Defines the 'language' entity field item.

Namespace

Drupal\Core\Field\Plugin\Field\FieldType

Code

public function onChange($property_name, $notify = TRUE) {

  // Make sure that the value and the language property stay in sync.
  if ($property_name == 'value') {
    $this
      ->writePropertyValue('language', $this->value);
  }
  elseif ($property_name == 'language') {
    $this
      ->writePropertyValue('value', $this
      ->get('language')
      ->getTargetIdentifier());
  }
  parent::onChange($property_name, $notify);
}