| Conditions | 5 |
| Paths | 8 |
| Total Lines | 180 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 138 | public function header( string $uid = '' ) : string |
||
| 139 | { |
||
| 140 | $config = $this->context()->config(); |
||
| 141 | $view = $this->object()->data( $this->view() ); |
||
| 142 | |||
| 143 | |||
| 144 | $addr = $view->extAddressItem; |
||
| 145 | |||
| 146 | $msg = $view->mail(); |
||
| 147 | $msg->header( 'X-MailGenerator', 'Aimeos' ); |
||
| 148 | $msg->to( $addr->getEMail(), $addr->getFirstName() . ' ' . $addr->getLastName() ); |
||
| 149 | |||
| 150 | |||
| 151 | $fromName = $config->get( 'resource/email/from-name' ); |
||
| 152 | |||
| 153 | /** client/html/email/from-name |
||
| 154 | * @see client/html/email/account/from-email |
||
| 155 | */ |
||
| 156 | $fromName = $config->get( 'client/html/email/from-name', $fromName ); |
||
| 157 | |||
| 158 | /** client/html/email/account/from-name |
||
| 159 | * Name used when sending account creation e-mails |
||
| 160 | * |
||
| 161 | * The name of the person or e-mail account that is used for sending all |
||
| 162 | * shop related account e-mails to customers. This configuration option |
||
| 163 | * overwrite the name set in "client/html/email/from-name". |
||
| 164 | * |
||
| 165 | * @param string Name shown in the e-mail |
||
| 166 | * @since 2015.09 |
||
| 167 | * @category User |
||
| 168 | * @see client/html/email/from-name |
||
| 169 | * @see client/html/email/from-email |
||
| 170 | * @see client/html/email/reply-email |
||
| 171 | * @see client/html/email/bcc-email |
||
| 172 | */ |
||
| 173 | $fromNameAccount = $config->get( 'client/html/email/account/from-name', $fromName ); |
||
| 174 | |||
| 175 | $fromEmail = $config->get( 'resource/email/from-email' ); |
||
| 176 | |||
| 177 | /** client/html/email/from-email |
||
| 178 | * @see client/html/email/account/from-email |
||
| 179 | */ |
||
| 180 | $fromEmail = $config->get( 'client/html/email/from-email', $fromEmail ); |
||
| 181 | |||
| 182 | /** client/html/email/account/from-email |
||
| 183 | * E-Mail address used when sending account creation e-mails |
||
| 184 | * |
||
| 185 | * The e-mail address of the person or account that is used for sending |
||
| 186 | * all shop related product notification e-mails to customers. This configuration option |
||
| 187 | * overwrites the e-mail address set via "client/html/email/from-email". |
||
| 188 | * |
||
| 189 | * @param string E-mail address |
||
| 190 | * @since 2015.09 |
||
| 191 | * @category User |
||
| 192 | * @see client/html/email/account/from-name |
||
| 193 | * @see client/html/email/from-email |
||
| 194 | * @see client/html/email/reply-email |
||
| 195 | * @see client/html/email/bcc-email |
||
| 196 | */ |
||
| 197 | if( ( $fromEmailAccount = $config->get( 'client/html/email/account/from-email', $fromEmail ) ) != null ) { |
||
| 198 | $msg->from( $fromEmailAccount, $fromNameAccount ); |
||
| 199 | } |
||
| 200 | |||
| 201 | |||
| 202 | /** client/html/email/reply-name |
||
| 203 | * @see client/html/email/account/reply-email |
||
| 204 | */ |
||
| 205 | $replyName = $config->get( 'client/html/email/reply-name', $fromName ); |
||
| 206 | |||
| 207 | /** client/html/email/account/reply-name |
||
| 208 | * Recipient name displayed when the customer replies to account creation e-mails |
||
| 209 | * |
||
| 210 | * The name of the person or e-mail account the customer should |
||
| 211 | * reply to in case of account related questions or problems. This |
||
| 212 | * configuration option overwrites the name set via |
||
| 213 | * "client/html/email/reply-name". |
||
| 214 | * |
||
| 215 | * @param string Name shown in the e-mail |
||
| 216 | * @since 2015.09 |
||
| 217 | * @category User |
||
| 218 | * @see client/html/email/account/reply-email |
||
| 219 | * @see client/html/email/reply-name |
||
| 220 | * @see client/html/email/reply-email |
||
| 221 | * @see client/html/email/from-email |
||
| 222 | * @see client/html/email/bcc-email |
||
| 223 | */ |
||
| 224 | $replyNameAccount = $config->get( 'client/html/email/account/reply-name', $replyName ); |
||
| 225 | |||
| 226 | /** client/html/email/reply-email |
||
| 227 | * @see client/html/email/account/reply-email |
||
| 228 | */ |
||
| 229 | $replyEmail = $config->get( 'client/html/email/reply-email', $fromEmail ); |
||
| 230 | |||
| 231 | /** client/html/email/account/reply-email |
||
| 232 | * E-Mail address used by the customer when replying to account creation e-mails |
||
| 233 | * |
||
| 234 | * The e-mail address of the person or e-mail account the customer |
||
| 235 | * should reply to in case of account related questions or problems. |
||
| 236 | * This configuration option overwrites the e-mail address set via |
||
| 237 | * "client/html/email/reply-email". |
||
| 238 | * |
||
| 239 | * @param string E-mail address |
||
| 240 | * @since 2015.09 |
||
| 241 | * @category User |
||
| 242 | * @see client/html/email/account/reply-name |
||
| 243 | * @see client/html/email/reply-email |
||
| 244 | * @see client/html/email/from-email |
||
| 245 | * @see client/html/email/bcc-email |
||
| 246 | */ |
||
| 247 | if( ( $replyEmailAccount = $config->get( 'client/html/email/account/reply-email', $replyEmail ) ) != null ) { |
||
| 248 | $msg->replyTo( $replyEmailAccount, $replyNameAccount ); |
||
| 249 | } |
||
| 250 | |||
| 251 | |||
| 252 | /** client/html/email/bcc-email |
||
| 253 | * @see client/html/email/account/bcc-email |
||
| 254 | */ |
||
| 255 | $bccEmail = $config->get( 'client/html/email/bcc-email' ); |
||
| 256 | |||
| 257 | /** client/html/email/account/bcc-email |
||
| 258 | * E-Mail address all account creation e-mails should be also sent to |
||
| 259 | * |
||
| 260 | * Using this option you can send a copy of all account related e-mails |
||
| 261 | * to a second e-mail account. This can be handy for testing and checking |
||
| 262 | * the e-mails sent to customers. |
||
| 263 | * |
||
| 264 | * It also allows shop owners with a very small volume of orders to be |
||
| 265 | * notified about account changes. Be aware that this isn't useful if the |
||
| 266 | * order volumne is high or has peeks! |
||
| 267 | * |
||
| 268 | * This configuration option overwrites the e-mail address set via |
||
| 269 | * "client/html/email/bcc-email". |
||
| 270 | * |
||
| 271 | * @param string|array E-mail address or list of e-mail addresses |
||
| 272 | * @since 2015.09 |
||
| 273 | * @category User |
||
| 274 | * @category Developer |
||
| 275 | * @see client/html/email/bcc-email |
||
| 276 | * @see client/html/email/reply-email |
||
| 277 | * @see client/html/email/from-email |
||
| 278 | */ |
||
| 279 | if( ( $bccEmailAccount = $config->get( 'client/html/email/account/bcc-email', $bccEmail ) ) != null ) |
||
| 280 | { |
||
| 281 | foreach( (array) $bccEmailAccount as $emailAddr ) { |
||
| 282 | $msg->Bcc( $emailAddr ); |
||
| 283 | } |
||
| 284 | } |
||
| 285 | |||
| 286 | |||
| 287 | /** client/html/email/account/template-header |
||
| 288 | * Relative path to the HTML header template of the account creation e-mail client. |
||
| 289 | * |
||
| 290 | * The template file contains the HTML code and processing instructions |
||
| 291 | * to generate the HTML code that is inserted into the HTML page header |
||
| 292 | * of the rendered page in the frontend. The configuration string is the |
||
| 293 | * path to the template file relative to the templates directory (usually |
||
| 294 | * in client/html/templates). |
||
| 295 | * |
||
| 296 | * You can overwrite the template file configuration in extensions and |
||
| 297 | * provide alternative templates. These alternative templates should be |
||
| 298 | * named like the default one but suffixed by |
||
| 299 | * an unique name. You may use the name of your project for this. If |
||
| 300 | * you've implemented an alternative client class as well, it |
||
| 301 | * should be suffixed by the name of the new class. |
||
| 302 | * |
||
| 303 | * The product notification e-mail HTML client allows to use a different template for |
||
| 304 | * each account status value. You can create a template for each account |
||
| 305 | * status and store it in the "email/account/<status number>/" directory |
||
| 306 | * below the "templates" directory (usually in client/html/templates). If no |
||
| 307 | * specific layout template is found, the common template in the |
||
| 308 | * "email/account/" directory is used. |
||
| 309 | * |
||
| 310 | * @param string Relative path to the template creating code for the HTML page head |
||
| 311 | * @since 2015.09 |
||
| 312 | * @category Developer |
||
| 313 | * @see client/html/email/account/template-body |
||
| 314 | */ |
||
| 315 | $tplconf = 'client/html/email/account/template-header'; |
||
| 316 | |||
| 317 | return $view->render( $view->config( $tplconf, 'email/account/header' ) ); ; |
||
| 318 | } |
||
| 448 |