5 use Drupal\Core\Field\Plugin\Field\FieldType\StringItem;
8 * Defines a custom field item class for the 'name' user entity field.
10 class UserNameItem extends StringItem {
15 public function isEmpty() {
16 $value = $this->get('value')->getValue();
18 // Take into account that the name of the anonymous user is an empty string.
19 if ($this->getEntity()->isAnonymous()) {
20 return $value === NULL;
23 return $value === NULL || $value === '';