6a53eb5d0629c38588ce33a5959e83a412d26e94
[yaffs-website] / web / core / modules / user / src / UserNameItem.php
1 <?php
2
3 namespace Drupal\user;
4
5 use Drupal\Core\Field\Plugin\Field\FieldType\StringItem;
6
7 /**
8  * Defines a custom field item class for the 'name' user entity field.
9  */
10 class UserNameItem extends StringItem {
11
12   /**
13    * {@inheritdoc}
14    */
15   public function isEmpty() {
16     $value = $this->get('value')->getValue();
17
18     // Take into account that the name of the anonymous user is an empty string.
19     if ($this->getEntity()->isAnonymous()) {
20       return $value === NULL;
21     }
22
23     return $value === NULL || $value === '';
24   }
25
26 }