ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
Email.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\User\Profile\Fields\NoOverrides;
28
29class Email implements FieldDefinition
30{
31 use NoOverrides;
32
33 public function getIdentifier(): string
34 {
35 return 'email';
36 }
37
38 public function getLabel(Language $lng): string
39 {
40 return $lng->txt($this->getIdentifier());
41 }
42
43 public function getSection(): AvailableSections
44 {
45 return AvailableSections::ContactData;
46 }
47
48 public function availableInCertificatesForcedTo(): ?bool
49 {
50 return false;
51 }
52
53 public function getLegacyInput(
56 ?\ilObjUser $user = null
58 $input = new \ilEMailInputGUI($this->getLabel($lng));
59 $input->setMaxLength(128);
60 if ($context === Context::Registration) {
61 $input->setRequired(true);
62 $input->setRetype(true);
63 }
64 if ($user === null) {
65 return $input;
66 }
67 $input->setValue(
68 $this->retrieveValueFromUser($user) ?? ''
69 );
70 return $input;
71 }
72
73 public function addValueToUserObject(
74 \ilObjUser $user,
75 mixed $input,
76 ?\ilPropertyFormGUI $form = null
77 ): \ilObjUser {
78 $user->setEmail(trim($input));
79 return $user;
80 }
81
82 public function retrieveValueFromUser(\ilObjUser $user): string
83 {
84 return $user->getEmail();
85 }
86}
addValueToUserObject(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
Definition: Email.php:73
getLegacyInput(Language $lng, Context $context, ?\ilObjUser $user=null)
You don't need to add a post_var to the input as the User will handle this for you,...
Definition: Email.php:53
retrieveValueFromUser(\ilObjUser $user)
Definition: Email.php:82
This class represents a email property in a property form.
setMaxLength(int $max_length)
This class represents a property in a property form.
User class.
This class represents a property form user interface.
global $lng
Definition: privfeed.php:31
$context
Definition: webdav.php:31