ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilMailMimeSubjectBuilder.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
27  public function __construct(private readonly ilSetting $settings, private readonly string $defaultPrefix)
28  {
29  }
30 
31  public function subject(string $subject, bool $addPrefix = false, string $contextPrefix = ''): string
32  {
33  $subject = trim($subject);
34  $contextPrefix = trim($contextPrefix);
35 
36  if ($addPrefix) {
37  // #9096
38  $globalPrefix = $this->settings->get('mail_subject_prefix');
39  if (!is_string($globalPrefix)) {
40  $globalPrefix = $this->defaultPrefix;
41  }
42  $globalPrefix = trim($globalPrefix);
43 
44  $prefix = $globalPrefix;
45  if ($contextPrefix !== '') {
46  $prefix = str_replace(['[', ']',], '', $prefix);
47  if ($prefix !== '') {
48  $prefix = '[' . $prefix . ' : ' . $contextPrefix . ']';
49  } else {
50  $prefix = '[' . $contextPrefix . ']';
51  }
52  }
53 
54  if ($prefix && $prefix !== '') {
55  $subject = $prefix . ' ' . $subject;
56  }
57  }
58 
59  return $subject;
60  }
61 }
__construct(private readonly ilSetting $settings, private readonly string $defaultPrefix)
Class ilMailMimeSubjectBuilder.
subject(string $subject, bool $addPrefix=false, string $contextPrefix='')