ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilUserDefinedFieldsPlaceholderValues.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
29{
30 public function __construct(
31 private readonly Language $lng,
32 private readonly ilCertificateObjectHelper $objectHelper,
33 private readonly Profile $user_profile,
34 private readonly ilCertificateUtilHelper $ilUtilHelper
35 ) {
36 }
37
47 public function getPlaceholderValues(int $userId, int $objId): array
48 {
50 $user = $this->objectHelper->getInstanceByObjId($userId);
51 if (!$user instanceof ilObjUser) {
52 throw new ilException('The entered id: ' . $userId . ' is not an user object');
53 }
54
55 $userDefinedFields = $this->user_profile->getVisibleUserDefinedFields(Context::Certificate);
56
57 $placeholder = [];
58 foreach ($userDefinedFields as $field) {
59 $placeholderText = '#' . str_replace(' ', '_', ilStr::strToUpper($field->getLabel($this->lng)));
60 $placeholder[$placeholderText] = $this->ilUtilHelper->prepareFormOutput(
61 $field->retrieveValueFromUser($user)
62 );
63 }
64
65 return $placeholder;
66 }
67
73 public function getPlaceholderValuesForPreview(int $userId, int $objId): array
74 {
75 $userDefinedFields = $this->user_profile->getDefinitions();
76
77 $placeholder = [];
78 foreach ($userDefinedFields as $field) {
79 if ($field['certificate']) {
80 $placeholderText = '#' . str_replace(' ', '_', ilStr::strToUpper($field['field_name']));
81
82 $placeholder[$placeholderText] = $field['field_name'];
83 }
84 }
85
86 return $placeholder;
87 }
88}
Just a wrapper class to create Unit Test for other classes.
Base class for ILIAS Exception handling.
User class.
static strToUpper(string $a_string)
Definition: class.ilStr.php:78
getPlaceholderValuesForPreview(int $userId, int $objId)
This method is different then the 'getPlaceholderValues' method, this method is used to create a plac...
__construct(private readonly Language $lng, private readonly ilCertificateObjectHelper $objectHelper, private readonly Profile $user_profile, private readonly ilCertificateUtilHelper $ilUtilHelper)
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
global $lng
Definition: privfeed.php:31
$objId
Definition: xapitoken.php:57