You are here

public function UserNameItem::isEmpty in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/user/src/UserNameItem.php \Drupal\user\UserNameItem::isEmpty()

Determines whether the data structure is empty.

Return value

bool TRUE if the data structure is empty, FALSE otherwise.

Overrides StringItemBase::isEmpty

File

core/modules/user/src/UserNameItem.php, line 16

Class

UserNameItem
Defines a custom field item class for the 'name' user entity field.

Namespace

Drupal\user

Code

public function isEmpty() {
  $value = $this
    ->get('value')
    ->getValue();

  // Take into account that the name of the anonymous user is an empty string.
  if ($this
    ->getEntity()
    ->isAnonymous()) {
    return $value === NULL;
  }
  return $value === NULL || $value === '';
}