Issues (2553)

lib/public/Mail/IEMailTemplate.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright 2017, Morris Jobke <[email protected]>
7
 *
8
 * @author Brad Rubenstein <[email protected]>
9
 * @author Joas Schilling <[email protected]>
10
 * @author Lukas Reschke <[email protected]>
11
 * @author Morris Jobke <[email protected]>
12
 * @author Roeland Jago Douma <[email protected]>
13
 *
14
 * @license GNU AGPL version 3 or any later version
15
 *
16
 * This program is free software: you can redistribute it and/or modify
17
 * it under the terms of the GNU Affero General Public License as
18
 * published by the Free Software Foundation, either version 3 of the
19
 * License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
 * GNU Affero General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU Affero General Public License
27
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
 *
29
 */
30
namespace OCP\Mail;
31
32
/**
33
 * Interface IEMailTemplate
34
 *
35
 * Interface to a class that allows to build HTML emails
36
 *
37
 * Example:
38
 *
39
 * <?php
40
 *
41
 * $emailTemplate = new EMailTemplate($this->defaults, $this->urlGenerator, $this->l10n);
42
 *
43
 * $emailTemplate->addHeader();
44
 * $emailTemplate->addHeading('Welcome aboard');
45
 * $emailTemplate->addBodyText('Welcome to your Nextcloud account, you can add, protect, and share your data.');
46
 *
47
 * $emailTemplate->addBodyButtonGroup(
48
 *     'Set your password', 'https://example.org/resetPassword/q1234567890qwertz',
49
 *     'Install Client', 'https://nextcloud.com/install/#install-clients'
50
 * );
51
 *
52
 * $emailTemplate->addFooter('Optional footer text');
53
 *
54
 * $htmlContent = $emailTemplate->renderHtml();
55
 * $plainContent = $emailTemplate->renderText();
56
 *
57
 * @since 12.0.0
58
 */
59
interface IEMailTemplate {
60
	/**
61
	 * Sets the subject of the email
62
	 *
63
	 * @param string $subject
64
	 *
65
	 * @since 13.0.0
66
	 */
67
	public function setSubject(string $subject);
68
69
	/**
70
	 * Adds a header to the email
71
	 *
72
	 * @since 12.0.0
73
	 */
74
	public function addHeader();
75
76
	/**
77
	 * Adds a heading to the email
78
	 *
79
	 * @param string $title
80
	 * @param string|bool $plainTitle Title that is used in the plain text email
81
	 *   if empty the $title is used, if false none will be used
82
	 *
83
	 * @since 12.0.0
84
	 */
85
	public function addHeading(string $title, $plainTitle = '');
86
87
	/**
88
	 * Adds a paragraph to the body of the email
89
	 *
90
	 * @param string $text; Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
91
	 * @param string|bool $plainText Text that is used in the plain text email
92
	 *   if empty the $text is used, if false none will be used
93
	 *
94
	 * @since 12.0.0
95
	 */
96
	public function addBodyText(string $text, $plainText = '');
97
98
	/**
99
	 * Adds a list item to the body of the email
100
	 *
101
	 * @param string $text; Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
102
	 * @param string $metaInfo; Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email
103
	 * @param string $icon Absolute path, must be 16*16 pixels
104
	 * @param string|bool $plainText Text that is used in the plain text email
105
	 *   if empty the $text is used, if false none will be used
106
	 * @param string|bool $plainMetaInfo Meta info that is used in the plain text email
107
	 *   if empty the $metaInfo is used, if false none will be used
108
	 * @param integer plainIndent If > 0, Indent plainText by this amount.
0 ignored issues
show
The type OCP\Mail\plainIndent was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
109
	 * @since 12.0.0
110
	 */
111
	public function addBodyListItem(string $text, string $metaInfo = '', string $icon = '', $plainText = '', $plainMetaInfo = '', $plainIndent = 0);
112
113
	/**
114
	 * Adds a button group of two buttons to the body of the email
115
	 *
116
	 * @param string $textLeft Text of left button; Note: When $plainTextLeft falls back to this, HTML is automatically escaped in the HTML email
117
	 * @param string $urlLeft URL of left button
118
	 * @param string $textRight Text of right button; Note: When $plainTextRight falls back to this, HTML is automatically escaped in the HTML email
119
	 * @param string $urlRight URL of right button
120
	 * @param string $plainTextLeft Text of left button that is used in the plain text version - if empty the $textLeft is used
121
	 * @param string $plainTextRight Text of right button that is used in the plain text version - if empty the $textRight is used
122
	 *
123
	 * @since 12.0.0
124
	 */
125
	public function addBodyButtonGroup(string $textLeft, string $urlLeft, string $textRight, string $urlRight, string $plainTextLeft = '', string $plainTextRight = '');
126
127
	/**
128
	 * Adds a button to the body of the email
129
	 *
130
	 * @param string $text Text of button; Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
131
	 * @param string $url URL of button
132
	 * @param string|false $plainText Text of button in plain text version
133
	 * 		if empty the $text is used, if false none will be used
134
	 *
135
	 * @since 12.0.0
136
	 */
137
	public function addBodyButton(string $text, string $url, $plainText = '');
138
139
	/**
140
	 * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email
141
	 *
142
	 * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used
143
	 * @param string $lang Optional language to set the default footer in
144
	 *
145
	 * @since 12.0.0
146
	 */
147
	public function addFooter(string $text = '', ?string $lang = null);
148
149
	/**
150
	 * Returns the rendered email subject as string
151
	 *
152
	 * @return string
153
	 *
154
	 * @since 13.0.0
155
	 */
156
	public function renderSubject(): string;
157
158
	/**
159
	 * Returns the rendered HTML email as string
160
	 *
161
	 * @return string
162
	 *
163
	 * @since 12.0.0
164
	 */
165
	public function renderHtml(): string;
166
167
	/**
168
	 * Returns the rendered plain text email as string
169
	 *
170
	 * @return string
171
	 *
172
	 * @since 12.0.0
173
	 */
174
	public function renderText(): string;
175
}
176