ILIAS  release_8 Revision v8.24
class.ilObjectCustomUserFieldsPlaceholderValues.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
28
29 public function __construct(
32 ) {
33 if (null === $objectHelper) {
35 }
36 $this->objectHelper = $objectHelper;
37 if (null === $utilHelper) {
39 }
40 $this->utilHelper = $utilHelper;
41 }
42
55 public function getPlaceholderValues(int $userId, int $objId): array
56 {
58 $user = $this->objectHelper->getInstanceByObjId($userId);
59 if (!$user instanceof ilObjUser) {
60 throw new ilException('The entered id: ' . $userId . ' is not an user object');
61 }
62
63 $course_defined_fields = ilCourseDefinedFieldDefinition::_getFields($objId);
65
66 $placeholder = [];
67 foreach ($course_defined_fields as $key => $field) {
68 $field_id = $field->getId();
69
70 $placeholderText = '+' . str_replace(' ', '_', ilStr::strToUpper($field->getName()));
71 $placeholder[$placeholderText] =
72 !empty($field_values[$userId][$field_id]) ?
73 $this->utilHelper->prepareFormOutput(trim($field_values[$userId][$field_id])) :
74 '';
75 }
76
77 return $placeholder;
78 }
79
88 public function getPlaceholderValuesForPreview(int $userId, int $objId): array
89 {
90 global $DIC;
91
92 $lng = $DIC->language();
93
94 $course_defined_fields = ilCourseDefinedFieldDefinition::_getFields($objId);
95
96 $placeholder = [];
97 foreach ($course_defined_fields as $key => $field) {
98 $placeholderText = '+' . str_replace(' ', '_', ilStr::strToUpper($field->getName()));
99
100 $placeholder[$placeholderText] = $placeholderText . '_' . ilStr::strToUpper($lng->txt('value'));
101 }
102
103 return $placeholder;
104 }
105}
Just a wrapper class to create Unit Test for other classes.
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
static _getValuesByObjId(int $a_obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
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, ?ilCertificateUtilHelper $utilHelper=null)
static strToUpper(string $a_string)
Definition: class.ilStr.php:81
global $DIC
Definition: feed.php:28
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
string $key
Consumer key/client ID value.
Definition: System.php:193
$lng
$objId
Definition: xapitoken.php:57