Chris@0: getEntity()) { Chris@0: $langcode = $this->getDefaultLangcode($entity); Chris@0: } Chris@0: // Always notify otherwise default langcode will not be set correctly. Chris@0: $this->setValue(['value' => $langcode], TRUE); Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Provides default language code of given entity. Chris@0: * Chris@0: * @param \Drupal\Core\Entity\EntityInterface $entity Chris@0: * The entity whose language code to be loaded. Chris@0: * Chris@0: * @return string Chris@0: * A string language code. Chris@0: */ Chris@0: public function getDefaultLangcode(EntityInterface $entity) { Chris@0: return language_get_default_langcode($entity->getEntityTypeId(), $entity->bundle()); Chris@0: } Chris@0: Chris@0: }