ILIAS  release_8 Revision v8.24
class.ilUserDefinedFieldsPlaceholderValues.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
29
30 public function __construct(
34 ) {
35 if (null === $objectHelper) {
37 }
38 $this->objectHelper = $objectHelper;
39
40 if (null === $userDefinedFieldsObject) {
42 }
43 $this->userDefinedFieldsObject = $userDefinedFieldsObject;
44
45 if (null === $ilUtilHelper) {
47 }
48 $this->ilUtilHelper = $ilUtilHelper;
49 }
50
63 public function getPlaceholderValues(int $userId, int $objId): array
64 {
66 $user = $this->objectHelper->getInstanceByObjId($userId);
67 if (!$user instanceof ilObjUser) {
68 throw new ilException('The entered id: ' . $userId . ' is not an user object');
69 }
70
71 $userDefinedFields = $this->userDefinedFieldsObject->getDefinitions();
72
73 $placeholder = [];
74 foreach ($userDefinedFields as $field) {
75 if ($field['certificate']) {
76 $placeholderText = '#' . str_replace(' ', '_', ilStr::strToUpper($field['field_name']));
77
78 $userDefinedData = $user->getUserDefinedData();
79
80 $userDefinedFieldValue = '';
81 if (isset($userDefinedData['f_' . $field['field_id']])) {
82 $userDefinedFieldValue = $this->ilUtilHelper->prepareFormOutput($userDefinedData['f_' . $field['field_id']]);
83 }
84
85 $placeholder[$placeholderText] = $userDefinedFieldValue;
86 }
87 }
88
89 return $placeholder;
90 }
91
100 public function getPlaceholderValuesForPreview(int $userId, int $objId): array
101 {
102 $userDefinedFields = $this->userDefinedFieldsObject->getDefinitions();
103
104 $placeholder = [];
105 foreach ($userDefinedFields as $field) {
106 if ($field['certificate']) {
107 $placeholderText = '#' . str_replace(' ', '_', ilStr::strToUpper($field['field_name']));
108
109 $placeholder[$placeholderText] = $field['field_name'];
110 }
111 }
112
113 return $placeholder;
114 }
115}
Just a wrapper class to create Unit Test for other classes.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
static strToUpper(string $a_string)
Definition: class.ilStr.php:81
getPlaceholderValuesForPreview(int $userId, int $objId)
This method is different then the 'getPlaceholderValues' method, this method is used to create a plac...
__construct(?ilCertificateObjectHelper $objectHelper=null, ?ilUserDefinedFields $userDefinedFieldsObject=null, ?ilCertificateUtilHelper $ilUtilHelper=null)
Additional user data fields definition.
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
$objId
Definition: xapitoken.php:57