function UserNameItem::isEmpty

Same name in other branches
  1. 8.9.x core/modules/user/src/UserNameItem.php \Drupal\user\UserNameItem::isEmpty()
  2. 10 core/modules/user/src/UserNameItem.php \Drupal\user\UserNameItem::isEmpty()
  3. 11.x core/modules/user/src/UserNameItem.php \Drupal\user\UserNameItem::isEmpty()

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 === '';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.