Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UserNameItem.php

function UserNameItem::isEmpty

Overrides StringItemBase::isEmpty

File

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

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal