function UserNameItem::isEmpty
Same name in other branches
- 9 core/modules/user/src/UserNameItem.php \Drupal\user\UserNameItem::isEmpty()
- 8.9.x core/modules/user/src/UserNameItem.php \Drupal\user\UserNameItem::isEmpty()
- 11.x core/modules/user/src/UserNameItem.php \Drupal\user\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\userCode
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.