ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
MailSignatureService.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Mail\Service;
22 
23 use ilIniFile;
28 use ilLanguage;
29 use ilSetting;
36 
38 {
39  public function __construct(
40  private readonly ilMustacheFactory $mustacheFactory,
41  private readonly ilIniFile $client_ini_file,
42  private readonly ilLanguage $lng,
43  private readonly ilSetting $settings
44  ) {
45  }
46 
47  public function installation(): string
48  {
49  return $this->processSignature(
50  $this->getPlaceholder(),
52  );
53  }
54 
55  public function user(int $user_id): string
56  {
57  return $this->processSignature(
58  $this->getPlaceholder($user_id),
59  new MailUserSignature($this->settings)
60  );
61  }
62 
63  private function processSignature(Placeholder $placeholder, Signature $signature): string
64  {
65  $placeholders = $placeholder->handle($signature);
66 
67  return "\n\n\n" . $this->mustacheFactory->getBasicEngine()->render($signature->getSignature(), $placeholders);
68  }
69 
70  public function getPlaceholder(int $user_id = 0): Placeholder
71  {
72  $ilias_url_ph = new MailSignatureIliasUrlPlaceholder($this->lng);
73  $installation_name_ph = new MailSignatureInstallationNamePlaceholder($this->lng, $this->client_ini_file);
74  $installation_description_ph = new MailSignatureInstallationDescriptionPlaceholder($this->lng);
75  $user_name_ph = new MailSignatureUserLoginPlaceholder($this->lng, $user_id);
76  $user_fullname_ph = new MailSignatureUserFullnamePlaceholder($this->lng, $user_id);
77  $ilias_url_ph
78  ->setNext($installation_name_ph)
79  ->setNext($installation_description_ph)
80  ->setNext($user_name_ph)
81  ->setNext($user_fullname_ph);
82 
83  return $ilias_url_ph;
84  }
85 }
handle(Signature $signature)
processSignature(Placeholder $placeholder, Signature $signature)
__construct(private readonly ilMustacheFactory $mustacheFactory, private readonly ilIniFile $client_ini_file, private readonly ilLanguage $lng, private readonly ilSetting $settings)
global $lng
Definition: privfeed.php:31