ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Birthday.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 Birthday implements FieldDefinition
30{
31 use NoOverrides;
32
33 public function getIdentifier(): string
34 {
35 return 'birthday';
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::PersonalData;
46 }
47
48 public function availableInCertificatesForcedTo(): ?bool
49 {
50 return true;
51 }
52
53 public function getLegacyInput(
56 ?\ilObjUser $user = null
58 $input = new \ilBirthdayInputGUI($this->getLabel($lng));
59 $value = $user === null ? '' : $this->retrieveValueFromUser($user);
60
61 if ($value === '') {
62 return $input;
63 }
64
65 $input->setDate(
66 new \ilDateTime($value, IL_CAL_DATE)
67 );
68 return $input;
69 }
70
71 public function addValueToUserObject(
72 \ilObjUser $user,
73 mixed $input,
74 ?\ilPropertyFormGUI $form = null
75 ): \ilObjUser {
76 $user->setBirthday($input);
77 return $user;
78 }
79
80 public function retrieveValueFromUser(\ilObjUser $user): ?string
81 {
82 return $user->getBirthday();
83 }
84}
addValueToUserObject(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
Definition: Birthday.php:71
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: Birthday.php:53
const IL_CAL_DATE
This class represents a text property in a property form.
@classDescription Date and time handling
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