ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Gender.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 Gender implements FieldDefinition
30{
31 use NoOverrides;
32
33 public function getIdentifier(): string
34 {
35 return 'gender';
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 \ilRadioGroupInputGUI($this->getLabel($lng));
59 $input->addOption(new \ilRadioOption($lng->txt('salutation_n'), Genders::Undisclosed->value));
60 $input->addOption(new \ilRadioOption($lng->txt('salutation_f'), Genders::Female->value));
61 $input->addOption(new \ilRadioOption($lng->txt('salutation_m'), Genders::Male->value));
62 if ($user === null) {
63 return $input;
64 }
65 $input->setValue(
66 $this->retrieveValueFromUser($user)
67 );
68 return $input;
69 }
70
71 public function addValueToUserObject(
72 \ilObjUser $user,
73 mixed $input,
74 ?\ilPropertyFormGUI $form = null
75 ): \ilObjUser {
76 $user->setGender($input);
77 return $user;
78 }
79
80 public function retrieveValueFromUser(\ilObjUser $user): string
81 {
82 return $user->getGender();
83 }
84}
addValueToUserObject(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
Definition: Gender.php:71
retrieveValueFromUser(\ilObjUser $user)
Definition: Gender.php:80
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: Gender.php:53
This class represents a property in a property form.
User class.
This class represents a property form user interface.
This class represents a property in a property form.
addOption(ilRadioOption $a_option)
This class represents an option in a radio group.
global $lng
Definition: privfeed.php:31
$context
Definition: webdav.php:31