| Conditions | 7 |
| Paths | 32 |
| Total Lines | 249 |
| Code Lines | 30 |
| 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 |
||
| 161 | public function getHeader( $uid = '' ) |
||
| 162 | { |
||
| 163 | $view = $this->getObject()->addData( $this->getView() ); |
||
| 164 | |||
| 165 | $content = ''; |
||
| 166 | foreach( $this->getSubClients() as $subclient ) { |
||
| 167 | $content .= $subclient->setView( $view )->getHeader( $uid ); |
||
| 168 | } |
||
| 169 | $view->deliveryHeader = $content; |
||
| 170 | |||
| 171 | |||
| 172 | $addr = $view->extAddressItem; |
||
| 173 | $billAddr = $view->extOrderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
||
| 174 | |||
| 175 | $msg = $view->mail(); |
||
| 176 | $msg->addHeader( 'X-MailGenerator', 'Aimeos' ); |
||
| 177 | $msg->addTo( $addr->getEMail(), $addr->getFirstName() . ' ' . $addr->getLastName() ); |
||
| 178 | |||
| 179 | if( $billAddr->getEMail() != $addr->getEmail() ) { |
||
| 180 | $msg->addCc( $billAddr->getEMail(), $billAddr->getFirstName() . ' ' . $billAddr->getLastName() ); |
||
| 181 | } |
||
| 182 | |||
| 183 | /** client/html/email/from-name |
||
| 184 | * Name used when sending e-mails |
||
| 185 | * |
||
| 186 | * The name of the person or e-mail account that is used for sending all |
||
| 187 | * shop related emails to customers. |
||
| 188 | * |
||
| 189 | * @param string Name shown in the e-mail |
||
| 190 | * @since 2014.03 |
||
| 191 | * @category User |
||
| 192 | * @see client/html/email/delivery/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 | $fromName = $view->config( 'client/html/email/from-name' ); |
||
| 198 | |||
| 199 | /** client/html/email/delivery/from-name |
||
| 200 | * Name used when sending delivery e-mails |
||
| 201 | * |
||
| 202 | * The name of the person or e-mail account that is used for sending all |
||
| 203 | * shop related delivery e-mails to customers. This configuration option |
||
| 204 | * overwrites the name set in "client/html/email/from-name". |
||
| 205 | * |
||
| 206 | * @param string Name shown in the e-mail |
||
| 207 | * @since 2014.03 |
||
| 208 | * @category User |
||
| 209 | * @see client/html/email/from-name |
||
| 210 | * @see client/html/email/from-email |
||
| 211 | * @see client/html/email/reply-email |
||
| 212 | * @see client/html/email/bcc-email |
||
| 213 | */ |
||
| 214 | $fromNameDelivery = $view->config( 'client/html/email/delivery/from-name', $fromName ); |
||
| 215 | |||
| 216 | /** client/html/email/from-email |
||
| 217 | * E-Mail address used when sending e-mails |
||
| 218 | * |
||
| 219 | * The e-mail address of the person or account that is used for sending |
||
| 220 | * all shop related emails to customers. |
||
| 221 | * |
||
| 222 | * @param string E-mail address |
||
| 223 | * @since 2014.03 |
||
| 224 | * @category User |
||
| 225 | * @see client/html/email/from-name |
||
| 226 | * @see client/html/email/delivery/from-email |
||
| 227 | * @see client/html/email/reply-email |
||
| 228 | * @see client/html/email/bcc-email |
||
| 229 | */ |
||
| 230 | $fromEmail = $view->config( 'client/html/email/from-email' ); |
||
| 231 | |||
| 232 | /** client/html/email/delivery/from-email |
||
| 233 | * E-Mail address used when sending delivery e-mails |
||
| 234 | * |
||
| 235 | * The e-mail address of the person or account that is used for sending |
||
| 236 | * all shop related delivery emails to customers. This configuration option |
||
| 237 | * overwrites the e-mail address set via "client/html/email/from-email". |
||
| 238 | * |
||
| 239 | * @param string E-mail address |
||
| 240 | * @since 2014.03 |
||
| 241 | * @category User |
||
| 242 | * @see client/html/email/delivery/from-name |
||
| 243 | * @see client/html/email/from-email |
||
| 244 | * @see client/html/email/reply-email |
||
| 245 | * @see client/html/email/bcc-email |
||
| 246 | */ |
||
| 247 | if( ( $fromEmailDelivery = $view->config( 'client/html/email/delivery/from-email', $fromEmail ) ) != null ) { |
||
| 248 | $msg->addFrom( $fromEmailDelivery, $fromNameDelivery ); |
||
| 249 | } |
||
| 250 | |||
| 251 | |||
| 252 | /** client/html/email/reply-name |
||
| 253 | * Recipient name displayed when the customer replies to e-mails |
||
| 254 | * |
||
| 255 | * The name of the person or e-mail account the customer should |
||
| 256 | * reply to in case of questions or problems. If no reply name is |
||
| 257 | * configured, the name person or e-mail account set via |
||
| 258 | * "client/html/email/from-name" is used. |
||
| 259 | * |
||
| 260 | * @param string Name shown in the e-mail |
||
| 261 | * @since 2014.03 |
||
| 262 | * @category User |
||
| 263 | * @see client/html/email/reply-email |
||
| 264 | * @see client/html/email/delivery/reply-email |
||
| 265 | * @see client/html/email/from-email |
||
| 266 | * @see client/html/email/from-name |
||
| 267 | * @see client/html/email/bcc-email |
||
| 268 | */ |
||
| 269 | $replyName = $view->config( 'client/html/email/reply-name', $fromName ); |
||
| 270 | |||
| 271 | /** client/html/email/delivery/reply-name |
||
| 272 | * Recipient name displayed when the customer replies to delivery e-mails |
||
| 273 | * |
||
| 274 | * The name of the person or e-mail account the customer should |
||
| 275 | * reply to in case of questions or problems. This configuration option |
||
| 276 | * overwrites the name set via "client/html/email/reply-name". |
||
| 277 | * |
||
| 278 | * @param string Name shown in the e-mail |
||
| 279 | * @since 2014.03 |
||
| 280 | * @category User |
||
| 281 | * @see client/html/email/delivery/reply-email |
||
| 282 | * @see client/html/email/reply-name |
||
| 283 | * @see client/html/email/reply-email |
||
| 284 | * @see client/html/email/from-email |
||
| 285 | * @see client/html/email/bcc-email |
||
| 286 | */ |
||
| 287 | $replyNameDelivery = $view->config( 'client/html/email/delivery/reply-name', $replyName ); |
||
| 288 | |||
| 289 | /** client/html/email/reply-email |
||
| 290 | * E-Mail address used by the customer when replying to e-mails |
||
| 291 | * |
||
| 292 | * The e-mail address of the person or e-mail account the customer |
||
| 293 | * should reply to in case of questions or problems. |
||
| 294 | * |
||
| 295 | * @param string E-mail address |
||
| 296 | * @since 2014.03 |
||
| 297 | * @category User |
||
| 298 | * @see client/html/email/reply-name |
||
| 299 | * @see client/html/email/delivery/reply-email |
||
| 300 | * @see client/html/email/from-email |
||
| 301 | * @see client/html/email/bcc-email |
||
| 302 | */ |
||
| 303 | $replyEmail = $view->config( 'client/html/email/reply-email', $fromEmail ); |
||
| 304 | |||
| 305 | /** client/html/email/delivery/reply-email |
||
| 306 | * E-Mail address used by the customer when replying to delivery e-mails |
||
| 307 | * |
||
| 308 | * The e-mail address of the person or e-mail account the customer |
||
| 309 | * should reply to in case of questions or problems. This configuration |
||
| 310 | * option overwrites the e-mail address set via "client/html/email/reply-email". |
||
| 311 | * |
||
| 312 | * @param string E-mail address |
||
| 313 | * @since 2014.03 |
||
| 314 | * @category User |
||
| 315 | * @see client/html/email/delivery/reply-name |
||
| 316 | * @see client/html/email/reply-email |
||
| 317 | * @see client/html/email/from-email |
||
| 318 | * @see client/html/email/bcc-email |
||
| 319 | */ |
||
| 320 | if( ( $replyEmailDelivery = $view->config( 'client/html/email/delivery/reply-email', $replyEmail ) ) != null ) { |
||
| 321 | $msg->addReplyTo( $replyEmailDelivery, $replyNameDelivery ); |
||
| 322 | } |
||
| 323 | |||
| 324 | |||
| 325 | /** client/html/email/bcc-email |
||
| 326 | * E-Mail address all e-mails should be also sent to |
||
| 327 | * |
||
| 328 | * Using this option you can send a copy of all shop related e-mails to |
||
| 329 | * a second e-mail account. This can be handy for testing and checking |
||
| 330 | * the e-mails sent to customers. |
||
| 331 | * |
||
| 332 | * It also allows shop owners with a very small volume of orders to be |
||
| 333 | * notified about new orders. Be aware that this isn't useful if the |
||
| 334 | * order volumne is high or has peeks! |
||
| 335 | * |
||
| 336 | * @param string E-mail address |
||
| 337 | * @since 2014.03 |
||
| 338 | * @category User |
||
| 339 | * @category Developer |
||
| 340 | * @see client/html/email/delivery/bcc-email |
||
| 341 | * @see client/html/email/reply-email |
||
| 342 | * @see client/html/email/from-email |
||
| 343 | */ |
||
| 344 | $bccEmail = $view->config( 'client/html/email/bcc-email' ); |
||
| 345 | |||
| 346 | /** client/html/email/delivery/bcc-email |
||
| 347 | * E-Mail address all delivery e-mails should be also sent to |
||
| 348 | * |
||
| 349 | * Using this option you can send a copy of all delivery related e-mails |
||
| 350 | * to a second e-mail account. This can be handy for testing and checking |
||
| 351 | * the e-mails sent to customers. |
||
| 352 | * |
||
| 353 | * It also allows shop owners with a very small volume of orders to be |
||
| 354 | * notified about new orders. Be aware that this isn't useful if the |
||
| 355 | * order volumne is high or has peeks! |
||
| 356 | * |
||
| 357 | * This configuration option overwrites the e-mail address set via |
||
| 358 | * "client/html/email/bcc-email". |
||
| 359 | * |
||
| 360 | * @param string|array E-mail address or list of e-mail addresses |
||
| 361 | * @since 2014.03 |
||
| 362 | * @category User |
||
| 363 | * @category Developer |
||
| 364 | * @see client/html/email/bcc-email |
||
| 365 | * @see client/html/email/reply-email |
||
| 366 | * @see client/html/email/from-email |
||
| 367 | */ |
||
| 368 | if( ( $bccEmailDelivery = $view->config( 'client/html/email/delivery/bcc-email', $bccEmail ) ) != null ) |
||
| 369 | { |
||
| 370 | foreach( (array) $bccEmailDelivery as $emailAddr ) { |
||
| 371 | $msg->addBcc( $emailAddr ); |
||
| 372 | } |
||
| 373 | } |
||
| 374 | |||
| 375 | |||
| 376 | /** client/html/email/delivery/standard/template-header |
||
| 377 | * Relative path to the text header template of the email delivery client. |
||
| 378 | * |
||
| 379 | * The template file contains the text and processing instructions |
||
| 380 | * to generate the text that is inserted into the header |
||
| 381 | * of the e-mail. The configuration string is the |
||
| 382 | * path to the template file relative to the templates directory (usually |
||
| 383 | * in client/html/templates). |
||
| 384 | * |
||
| 385 | * You can overwrite the template file configuration in extensions and |
||
| 386 | * provide alternative templates. These alternative templates should be |
||
| 387 | * named like the default one but with the string "standard" replaced by |
||
| 388 | * an unique name. You may use the name of your project for this. If |
||
| 389 | * you've implemented an alternative client class as well, "standard" |
||
| 390 | * should be replaced by the name of the new class. |
||
| 391 | * |
||
| 392 | * The email payment text client allows to use a different template for |
||
| 393 | * each payment status value. You can create a template for each payment |
||
| 394 | * status and store it in the "email/payment/<status number>/" directory |
||
| 395 | * below the "templates" directory (usually in client/html/templates). If no |
||
| 396 | * specific layout template is found, the common template in the |
||
| 397 | * "email/payment/" directory is used. |
||
| 398 | * |
||
| 399 | * @param string Relative path to the template creating code for the e-mail header |
||
| 400 | * @since 2014.03 |
||
| 401 | * @category Developer |
||
| 402 | * @see client/html/email/delivery/standard/template-body |
||
| 403 | */ |
||
| 404 | $tplconf = 'client/html/email/delivery/standard/template-header'; |
||
| 405 | |||
| 406 | $status = $view->extOrderItem->getDeliveryStatus(); |
||
| 407 | $default = array( 'email/delivery/' . $status . '/header-standard', 'email/delivery/header-standard' ); |
||
| 408 | |||
| 409 | return $view->render( $view->config( $tplconf, $default ) ); ; |
||
| 410 | } |
||
| 588 | } |