ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilMailMimeSubjectBuilder.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
11 private $settings;
14
21 {
22 $this->settings = $settings;
23 $this->defaultPrefix = $defaultPrefix;
24 }
25
32 public function subject(string $subject, bool $addPrefix = false, string $contextPrefix = '') : string
33 {
34 $subject = trim($subject);
35 $contextPrefix = trim($contextPrefix);
36
37 if ($addPrefix) {
38 // #9096
39 $globalPrefix = $this->settings->get('mail_subject_prefix', false);
40 if (!is_string($globalPrefix)) {
41 $globalPrefix = $this->defaultPrefix;
42 }
43 $globalPrefix = trim($globalPrefix);
44
45 $prefix = $globalPrefix;
46 if ($contextPrefix !== '') {
47 $prefix = str_replace(['[', ']',], '', $prefix);
48 if ($prefix !== '') {
49 $prefix = '[' . $prefix . ' : ' . $contextPrefix . ']';
50 } else {
51 $prefix = '[' . $contextPrefix . ']';
52 }
53 }
54
55 if (strlen($prefix) > 0) {
56 $subject = $prefix . ' ' . $subject;
57 }
58 }
59
60 return $subject;
61 }
62}
An exception for terminatinating execution or to throw for unit testing.
Class ilMailMimeSubjectBuilder.
__construct(ilSetting $settings, string $defaultPrefix)
ilMailMimeSubjectBuilder constructor.
subject(string $subject, bool $addPrefix=false, string $contextPrefix='')
ILIAS Setting Class.
settings()
Definition: settings.php:2