function LanguageItem::onChange

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php \Drupal\Core\Field\Plugin\Field\FieldType\LanguageItem::onChange()
  2. 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php \Drupal\Core\Field\Plugin\Field\FieldType\LanguageItem::onChange()
  3. 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php \Drupal\Core\Field\Plugin\Field\FieldType\LanguageItem::onChange()

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.