ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Utilities.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\Refinery\Factory as Refinery;
25
27{
28 protected \ilLanguage $lng;
29 protected \ilObjUser $user;
31
32 public function __construct(
36 ) {
37 $this->lng = $lng;
38 $this->lng->loadLanguageModule('meta');
39 $this->user = $user;
40 $this->refinery = $refinery;
41 }
42
43 public function getUserDateFormat(): DateFormat
44 {
45 return $this->user->getDateFormat();
46 }
47
48 public function txt(string $key): string
49 {
50 return $this->lng->txt($key);
51 }
52
53 public function txtFill(string $key, string ...$values): string
54 {
55 if ($this->lng->exists($key)) {
56 return sprintf($this->lng->txt($key), ...$values);
57 }
58 return $key . ' ' . implode(', ', $values);
59 }
60
61 public function sanitizeForHTML(string $string): string
62 {
63 return $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($string);
64 }
65}
A Date Format provides a format definition akin to PHP's date formatting options, but stores the sing...
Definition: DateFormat.php:27
Builds data types.
Definition: Factory.php:36
__construct(\ilLanguage $lng, \ilObjUser $user, Refinery $refinery)
Definition: Utilities.php:32
txtFill(string $key, string ... $values)
Definition: Utilities.php:53
language handling
User class.