language) && $this->id) { $this->language = \Drupal::languageManager()->getLanguage($this->id); } return $this->language; } /** * Overrides TypedData::setValue(). * * Both the langcode and the language object may be passed as value. */ public function setValue($value, $notify = TRUE) { // Support passing language objects. if (is_object($value)) { $this->id = $value->getId(); $this->language = $value; } elseif (isset($value) && !is_scalar($value)) { throw new \InvalidArgumentException('Value is no valid langcode or language object.'); } else { $this->id = $value; $this->language = NULL; } // Notify the parent of any changes. if ($notify && isset($this->parent)) { $this->parent->onChange($this->name); } } /** * {@inheritdoc} */ public function getString() { $language = $this->getValue(); return $language ? $language->getName() : ''; } /** * {@inheritdoc} */ public function id() { if (isset($this->id)) { return $this->id; } elseif (isset($this->language)) { return $this->language->getId(); } } }