Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/src/UserNameItem.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
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 } |