Change record status: 
Project: 
Description: 

Entity benefits from a new method, ::getLanguageCode(), that allows to retrieve the language code of the entity. Until now, the language code was obtained from the entity ::language() method.

Before (not recommended)

Until now we had to get first the language object from the entity and then obtain its ID (language code). This way of getting the language code is still working but it's not recommended.:

$langcode = $entity->language()->getId();

After (recommended)

$langcode = $entity->getLanguageCode();
Impacts: 
Module developers
Themers

Comments

subson’s picture

This is not merged to core and its not working, so this change record should be removed -
$langcode = $entity->getLanguageCode();

anybody’s picture

@claudiu.cristea could you please check that comment and clarify what happened here?

http://www.DROWL.de || Professionelle Drupal Lösungen aus Ostwestfalen-Lippe (OWL)
http://www.webks.de || webks: websolutions kept simple - Webbasierte Lösungen die einfach überzeugen!
http://www.drupal-theming.com || Individuelle Responsive Themes

rossb89’s picture

Yup, confirmed, this appears to have not been merged into core.

joseph.olstad’s picture

This is a draft change record, still pending the related issue.
#2303877: Remove cached languages from ContentEntityBase

anybody’s picture

Thanks @joseph.olstad! You're right, but as we can see here (and same happened to me once), this isn't very clear.

People find these Change Records and think they're live. I guess that should be indicated more clearly?

http://www.DROWL.de || Professionelle Drupal Lösungen aus Ostwestfalen-Lippe (OWL)
http://www.webks.de || webks: websolutions kept simple - Webbasierte Lösungen die einfach überzeugen!
http://www.drupal-theming.com || Individuelle Responsive Themes