Skip to content

Commit c05b10d

Browse files
author
Erik Hansen
committed
MAGETWO-37672: Responsive Email Foundation
- Simplified the retrieval of email variables
1 parent e333d70 commit c05b10d

File tree

1 file changed

+20
-37
lines changed

1 file changed

+20
-37
lines changed

app/code/Magento/Email/Model/AbstractTemplate.php

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ public function getProcessedTemplate(array $variables = [])
343343
}
344344
$processor->setStoreId($storeId);
345345

346-
// Populate the variables array with store, store info, logo, etc. variables
347-
$variables = $this->addEmailVariables($variables, $storeId);
346+
// Populate the variables array with store, store info, logo, etc.
347+
$variables += $this->getEmailVariables($storeId);
348348
$processor->setVariables($variables);
349349

350350
try {
@@ -420,62 +420,45 @@ protected function getLogoAlt($store)
420420
}
421421

422422
/**
423-
* Add variables that are used by transactional and newsletter emails
423+
* Returns variables that are used by transactional and newsletter emails
424424
*
425-
* @param array $variables
426425
* @param null|string|bool|int|\Magento\Store\Model\Store $storeId
427426
* @return mixed
428-
*
429-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
430-
* @SuppressWarnings(PHPMD.NPathComplexity)
431427
*/
432-
protected function addEmailVariables($variables, $storeId)
428+
protected function getEmailVariables($storeId)
433429
{
434430
$store = $this->storeManager->getStore($storeId);
435-
if (!isset($variables['store'])) {
436-
$variables['store'] = $store;
437-
}
438-
if (!isset($variables['logo_url'])) {
439-
$variables['logo_url'] = $this->getLogoUrl($storeId);
440-
}
441-
if (!isset($variables['logo_alt'])) {
442-
$variables['logo_alt'] = $this->getLogoAlt($storeId);
443-
}
444-
if (!isset($variables['logo_width'])) {
445-
$variables['logo_width'] = $this->scopeConfig->getValue(
431+
432+
$variables = [
433+
'store' => $store,
434+
'logo_url' => $this->getLogoUrl($storeId),
435+
'logo_alt' => $this->getLogoAlt($storeId),
436+
'logo_width' => $this->scopeConfig->getValue(
446437
self::XML_PATH_DESIGN_EMAIL_LOGO_WIDTH,
447438
ScopeInterface::SCOPE_STORE,
448439
$store
449-
);
450-
}
451-
if (!isset($variables['logo_height'])) {
452-
$variables['logo_height'] = $this->scopeConfig->getValue(
440+
),
441+
'logo_height' => $this->scopeConfig->getValue(
453442
self::XML_PATH_DESIGN_EMAIL_LOGO_HEIGHT,
454443
ScopeInterface::SCOPE_STORE,
455444
$store
456-
);
457-
}
458-
if (!isset($variables['store_phone'])) {
459-
$variables['store_phone'] = $this->scopeConfig->getValue(
445+
),
446+
'store_phone' => $this->scopeConfig->getValue(
460447
\Magento\Store\Model\Store::XML_PATH_STORE_STORE_PHONE,
461448
ScopeInterface::SCOPE_STORE,
462449
$store
463-
);
464-
}
465-
if (!isset($variables['store_hours'])) {
466-
$variables['store_hours'] = $this->scopeConfig->getValue(
450+
),
451+
'store_hours' => $this->scopeConfig->getValue(
467452
\Magento\Store\Model\Store::XML_PATH_STORE_STORE_HOURS,
468453
ScopeInterface::SCOPE_STORE,
469454
$store
470-
);
471-
}
472-
if (!isset($variables['store_email'])) {
473-
$variables['store_email'] = $this->scopeConfig->getValue(
455+
),
456+
'store_email' => $this->scopeConfig->getValue(
474457
'trans_email/ident_support/email',
475458
ScopeInterface::SCOPE_STORE,
476459
$store
477-
);
478-
}
460+
),
461+
];
479462
// If template is text mode, don't include styles
480463
if (!$this->isPlain() && !isset($variables['template_styles'])) {
481464
$variables['template_styles'] = $this->getTemplateStyles();

0 commit comments

Comments
 (0)