ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Repository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
25 private const TABLE_NAME = 'mail_template';
26 private const TYPE = 'nacc';
27
28 public function __construct(
29 private readonly \ilDBInterface $db
30 ) {
31 }
32
33 public function getFor(string $lang_code): Mail
34 {
35 $result_object = $this->db->fetchObject(
36 $this->db->query(
37 'SELECT * FROM ' . self::TABLE_NAME . ' WHERE type = "' . self::TYPE
38 . '" AND lang = "' . $lang_code . '"'
39 )
40 );
41
42 if ($result_object === null) {
43 return new MailImplementation($lang_code);
44 }
45
46 return new MailImplementation(
47 $result_object->lang,
48 trim($result_object->subject),
49 trim($result_object->body ?? ''),
50 trim($result_object->sal_g),
51 trim($result_object->sal_m),
52 trim($result_object->sal_f),
53 $result_object->att_rid,
54 $result_object->att_file ?? null
55 );
56 }
57
58 public function store(Mail $account_mail): void
59 {
60 $this->db->replace(
61 self::TABLE_NAME,
62 [
63 'lang' => [\ilDBConstants::T_TEXT, $account_mail->getLangCode()],
64 'type' => [\ilDBConstants::T_TEXT, self::TYPE]
65 ],
66 $account_mail->toStorage()
67 );
68 }
69}
__construct(private readonly \ilDBInterface $db)
Definition: Repository.php:28
Interface ilDBInterface.
RFC 822 Email address list validation Utility.