ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Utilities.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 
26 class Utilities implements UtilitiesInterface
27 {
28  protected \ilLanguage $lng;
29  protected \ilObjUser $user;
30  protected Refinery $refinery;
31 
32  public function __construct(
33  \ilLanguage $lng,
34  \ilObjUser $user,
35  Refinery $refinery
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 }
__construct(\ilLanguage $lng, \ilObjUser $user, Refinery $refinery)
Definition: Utilities.php:32
txtFill(string $key, string ... $values)
Definition: Utilities.php:53
A Date Format provides a format definition akin to PHP&#39;s date formatting options, but stores the sing...
Definition: DateFormat.php:26