ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ZipCode.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 ZipCode implements FieldDefinition
30{
31 use NoOverrides;
32
33 public function getIdentifier(): string
34 {
35 return 'zipcode';
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 true;
51 }
52
53 public function getLegacyInput(
56 ?\ilObjUser $user = null
58 $input = new \ilTextInputGUI($this->getLabel($lng));
59 $input->setMaxLength(40);
60 if ($user === null) {
61 return $input;
62 }
63 $input->setValue(
64 $this->retrieveValueFromUser($user)
65 );
66 return $input;
67 }
68
69 public function addValueToUserObject(
70 \ilObjUser $user,
71 mixed $input,
72 ?\ilPropertyFormGUI $form = null
73 ): \ilObjUser {
74 $user->setZipcode($input);
75 return $user;
76 }
77
78 public function retrieveValueFromUser(\ilObjUser $user): string
79 {
80 return $user->getZipcode();
81 }
82}
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: ZipCode.php:53
addValueToUserObject(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
Definition: ZipCode.php:69
This class represents a property in a property form.
User class.
This class represents a property form user interface.
This class represents a text property in a property form.
setMaxLength(?int $a_maxlength)
global $lng
Definition: privfeed.php:31
$context
Definition: webdav.php:31