ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ProfileBadgeGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\User\Badges;
22
25use Psr\Http\Message\RequestInterface;
26
28{
29 public function __construct(
30 private readonly Language $lng,
31 private readonly RequestInterface $request
32 ) {
33 }
34
35 public function initConfigForm(
36 \ilPropertyFormGUI $form,
37 int $parent_ref_id
38 ): void {
39 $fields = new \ilCheckboxGroupInputGUI(
40 $this->lng->txt('profile'),
41 'profile'
42 );
43 $form->addItem($fields);
44
45 (new PersonalProfileGUI())->showPublicProfileFields($form, [], $fields, true);
46 }
47
48 public function importConfigToForm(
49 \ilPropertyFormGUI $form,
50 array $config
51 ): void {
52 if (!is_array($config['profile'])) {
53 return;
54 }
55
56 foreach ($form->getItemByPostVar('profile')->getSubItems() as $field) {
57 foreach ($config['profile'] as $id) {
58 if ($field->getPostVar() === $id) {
59 $field->setChecked(true);
60 break;
61 }
62 }
63 }
64 }
65
69 public function getConfigFromForm(
71 ): array {
72 return ['profile' => array_reduce(
73 array_keys($this->request->getParsedBody()),
74 static function (array $c, string $v): array {
75 if (str_starts_with($v, 'chk_')) {
76 $c[] = $v;
77 }
78 return $c;
79 },
80 []
81 )];
82 }
83
84 public function validateForm(\ilPropertyFormGUI $form): bool
85 {
86 return true;
87 }
88}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getConfigFromForm(\ilPropertyFormGUI $form)
__construct(private readonly Language $lng, private readonly RequestInterface $request)
importConfigToForm(\ilPropertyFormGUI $form, array $config)
initConfigForm(\ilPropertyFormGUI $form, int $parent_ref_id)
validateForm(\ilPropertyFormGUI $form)
This class represents a property in a property form.
This class represents a property form user interface.
getItemByPostVar(string $a_post_var)
$c
Definition: deliver.php:25
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))