How do I define a computed field equal to the concatenation of two fields of my custom entity? I have a custom entity (Person) with these fields: ID, nom, prenom, telephoneportable, estactive, userID, created, changed. I created it with baseFieldDefinitions.  

I want to have a computed field nomprenom = nom ." ".prenom
Here is the corresponding code:  

$fields['nomprenom'] = BaseFieldDefinition::create('string')  
  -&gt;setLabel(t('Nom et Prénom'))  
  -&gt;setComputed(TRUE)  
  -&gt;setClass('\Drupal\association\NomPrenom');  


The code of class 'NomPrenom' is here:  

/**
 * @file
 * Contains \Drupal\association\NomPrenom.
 */

namespace Drupal\association;

use Drupal\Component\Utility\String;
use Drupal\Core\TypedData\DataDefinitionInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\Core\TypedData\TypedData;

/**
 * A computed property for defining 'Nom Prénom'.
 */
class NomPrenom extends TypedData {

  /**
   * Cached processed value.
   *
   * @var string|null
   */
  protected $processed = NULL;

  /**
   * Implements \Drupal\Core\TypedData\TypedDataInterface::getValue().
   */
  public function getValue($langcode = NULL) {
    if ($this-&gt;processed !== NULL) {
      return $this-&gt;processed;
    }

    $this-&gt;processed = $this-&gt;get('nom')-&gt;value ." ". $this-&gt;get('prenom')-&gt;value;
    return $this-&gt;processed;
  }

  /**
   * Implements \Drupal\Core\TypedData\TypedDataInterface::setValue().
   */
  public function setValue($value, $notify = TRUE) {
    $this-&gt;processed = $value;

    // Notify the parent of any changes.
    if ($notify &amp;&amp; isset($this-&gt;parent)) {
      $this-&gt;parent-&gt;onChange($this-&gt;name);
    }
  }

}  


When I try to add a new Person, I get a PHP Fatal error:  


  Call to undefined method Drupal\association\NomPrenom::setLangcode()  


Why?
I found this in ContentEntityBase.php 499 (but you could show us the whole error log):

I think the case is the following: your field is translatable (you didn't set it's not, and I tihnk the default is TRUE).  

else {
  $field_langcode = $langcode;
}
**$field-&gt;setLangcode($field_langcode);**
$this-&gt;fields[$name][$langcode] = $field;


What I don't understand here: how basefield definition allows you to add a class which doesn't inherit / implements the right class / interface. I think it's a core bug?

You should either:
- add set language method, with a languagecode property
- set your computed field untranslatable