Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
AbstractTemplate Class Reference
Inheritance diagram for AbstractTemplate:
AbstractModel TemplateTypesInterface DataObject Template Template BackendTemplate

Public Member Functions

 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\View\Asset\Repository $assetRepo, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Email\Model\Template\Config $emailConfig, \Magento\Email\Model\TemplateFactory $templateFactory, \Magento\Framework\Filter\FilterManager $filterManager, \Magento\Framework\UrlInterface $urlModel, array $data=[])
 
 getTemplateContent ($configPath, array $variables)
 
 loadByConfigPath ($configPath)
 
 loadDefault ($templateId)
 
 getProcessedTemplate (array $variables=[])
 
 getDefaultEmailLogo ()
 
 setForcedArea ($templateId)
 
 setForcedTheme ($templateId, $theme)
 
 getDesignParams ()
 
 getDesignConfig ()
 
 setDesignConfig (array $config)
 
 isChildTemplate ()
 
 setIsChildTemplate ($isChildTemplate)
 
 setTemplateFilter (Template\Filter $filter)
 
 getTemplateFilter ()
 
 emulateDesign ($storeId, $area=self::DEFAULT_DESIGN_AREA)
 
 revertDesign ()
 
 isPlain ()
 
 getType ()
 
 getUrl (Store $store, $route='', $params=[])
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 __sleep ()
 
 __wakeup ()
 
 setIdFieldName ($name)
 
 getIdFieldName ()
 
 getId ()
 
 setId ($value)
 
 isDeleted ($isDeleted=null)
 
 hasDataChanges ()
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 setDataChanges ($value)
 
 getOrigData ($key=null)
 
 setOrigData ($key=null, $data=null)
 
 dataHasChangedFor ($field)
 
 getResourceName ()
 
 getResourceCollection ()
 
 getCollection ()
 
 load ($modelId, $field=null)
 
 beforeLoad ($identifier, $field=null)
 
 afterLoad ()
 
 isSaveAllowed ()
 
 setHasDataChanges ($flag)
 
 save ()
 
 afterCommitCallback ()
 
 isObjectNew ($flag=null)
 
 beforeSave ()
 
 validateBeforeSave ()
 
 getCacheTags ()
 
 cleanModelCache ()
 
 afterSave ()
 
 delete ()
 
 beforeDelete ()
 
 afterDelete ()
 
 afterDeleteCommit ()
 
 getResource ()
 
 getEntityId ()
 
 setEntityId ($entityId)
 
 clearInstance ()
 
 getStoredData ()
 
 getEventPrefix ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Data Fields

const DEFAULT_DESIGN_AREA = 'frontend'
 
const DEFAULT_LOGO_FILE_ID = 'Magento_Email::logo_email.png'
 
const XML_PATH_DESIGN_EMAIL_LOGO = 'design/email/logo'
 
const XML_PATH_DESIGN_EMAIL_LOGO_ALT = 'design/email/logo_alt'
 
const XML_PATH_DESIGN_EMAIL_LOGO_WIDTH = 'design/email/logo_width'
 
const XML_PATH_DESIGN_EMAIL_LOGO_HEIGHT = 'design/email/logo_height'
 
- Data Fields inherited from TemplateTypesInterface
const TYPE_TEXT = 1
 
const TYPE_HTML = 2
 

Protected Member Functions

 getTemplateInstance ()
 
 getLogoUrl ($store)
 
 getLogoAlt ($store)
 
 addEmailVariables ($variables, $storeId)
 
 applyDesignConfig ()
 
 cancelDesignConfig ()
 
 getFilterFactory ()
 
- Protected Member Functions inherited from AbstractModel
 _construct ()
 
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $collectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($modelId, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _getValidatorBeforeSave ()
 
 _createValidatorBeforeSave ()
 
 _getValidationRulesBeforeSave ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $templateFactory = null
 
 $design = null
 
 $appEmulation
 
 $storeManager
 
 $assetRepo
 
 $filesystem
 
 $scopeConfig
 
 $emailConfig
 
 $filterManager
 
- Protected Attributes inherited from AbstractModel
 $_eventPrefix = 'core_abstract'
 
 $_eventObject = 'object'
 
 $_idFieldName = 'id'
 
 $_hasDataChanges = false
 
 $_origData
 
 $_isDeleted = false
 
 $_resource
 
 $_resourceCollection
 
 $_resourceName
 
 $_collectionName
 
 $_cacheTag = false
 
 $_dataSaveAllowed = true
 
 $_isObjectNew = null
 
 $_validatorBeforeSave = null
 
 $_eventManager
 
 $_cacheManager
 
 $_registry
 
 $_logger
 
 $_appState
 
 $_actionValidator
 
 $storedData = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Template model class

Author
Magento Core Team core@.nosp@m.mage.nosp@m.ntoco.nosp@m.mmer.nosp@m.ce.co.nosp@m.m @SuppressWarnings(PHPMD.CouplingBetweenObjects) @SuppressWarnings(PHPMD.TooManyFields) @api
Since
100.0.2

Definition at line 27 of file AbstractTemplate.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Model\Context  $context,
\Magento\Framework\View\DesignInterface  $design,
\Magento\Framework\Registry  $registry,
\Magento\Store\Model\App\Emulation  $appEmulation,
\Magento\Store\Model\StoreManagerInterface  $storeManager,
\Magento\Framework\View\Asset\Repository  $assetRepo,
\Magento\Framework\Filesystem  $filesystem,
\Magento\Framework\App\Config\ScopeConfigInterface  $scopeConfig,
\Magento\Email\Model\Template\Config  $emailConfig,
\Magento\Email\Model\TemplateFactory  $templateFactory,
\Magento\Framework\Filter\FilterManager  $filterManager,
\Magento\Framework\UrlInterface  $urlModel,
array  $data = [] 
)
Parameters
\Magento\Framework\Model\Context$context
\Magento\Framework\View\DesignInterface$design
\Magento\Framework\Registry$registry
\Magento\Store\Model\App\Emulation$appEmulation
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Framework\View\Asset\Repository$assetRepo
\Magento\Framework\Filesystem$filesystem
\Magento\Framework\App\Config\ScopeConfigInterface$scopeConfig
\Magento\Email\Model\Template\Config$emailConfig
\Magento\Email\Model\TemplateFactory$templateFactory
\Magento\Framework\Filter\FilterManager$filterManager
\Magento\Framework\UrlInterface$urlModel
array$data@SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 183 of file AbstractTemplate.php.

197  {
198  $this->design = $design;
199  $this->area = isset($data['area']) ? $data['area'] : null;
200  $this->store = isset($data['store']) ? $data['store'] : null;
201  $this->appEmulation = $appEmulation;
202  $this->storeManager = $storeManager;
203  $this->assetRepo = $assetRepo;
204  $this->filesystem = $filesystem;
205  $this->scopeConfig = $scopeConfig;
206  $this->emailConfig = $emailConfig;
207  $this->templateFactory = $templateFactory;
208  $this->filterManager = $filterManager;
209  $this->urlModel = $urlModel;
210  parent::__construct($context, $registry, null, null, $data);
211  }

Member Function Documentation

◆ addEmailVariables()

addEmailVariables (   $variables,
  $storeId 
)
protected

Add variables that are used by transactional and newsletter emails

Parameters
array$variables
null | string | bool | int | Store$storeId
Returns
mixed

@SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity)

Definition at line 436 of file AbstractTemplate.php.

437  {
438  $store = $this->storeManager->getStore($storeId);
439  if (!isset($variables['store'])) {
440  $variables['store'] = $store;
441  }
442  if (!isset($variables['logo_url'])) {
443  $variables['logo_url'] = $this->getLogoUrl($storeId);
444  }
445  if (!isset($variables['logo_alt'])) {
446  $variables['logo_alt'] = $this->getLogoAlt($storeId);
447  }
448  if (!isset($variables['logo_width'])) {
449  $variables['logo_width'] = $this->scopeConfig->getValue(
450  self::XML_PATH_DESIGN_EMAIL_LOGO_WIDTH,
452  $store
453  );
454  }
455  if (!isset($variables['logo_height'])) {
456  $variables['logo_height'] = $this->scopeConfig->getValue(
457  self::XML_PATH_DESIGN_EMAIL_LOGO_HEIGHT,
459  $store
460  );
461  }
462  if (!isset($variables['store_phone'])) {
463  $variables['store_phone'] = $this->scopeConfig->getValue(
464  StoreInformation::XML_PATH_STORE_INFO_PHONE,
466  $store
467  );
468  }
469  if (!isset($variables['store_hours'])) {
470  $variables['store_hours'] = $this->scopeConfig->getValue(
471  StoreInformation::XML_PATH_STORE_INFO_HOURS,
473  $store
474  );
475  }
476  if (!isset($variables['store_email'])) {
477  $variables['store_email'] = $this->scopeConfig->getValue(
478  'trans_email/ident_support/email',
480  $store
481  );
482  }
483  // If template is text mode, don't include styles
484  if (!$this->isPlain() && !isset($variables['template_styles'])) {
485  $variables['template_styles'] = $this->getTemplateStyles();
486  }
487 
488  return $variables;
489  }

◆ applyDesignConfig()

applyDesignConfig ( )
protected

Apply design config so that emails are processed within the context of the appropriate area/store/theme. Can be called multiple times without issue.

Returns
bool

Definition at line 497 of file AbstractTemplate.php.

498  {
499  // Only run app emulation if this is the parent template and emulation isn't already running.
500  // Otherwise child will run inside parent emulation.
501  if ($this->isChildTemplate() || $this->hasDesignBeenApplied) {
502  return false;
503  }
504  $this->hasDesignBeenApplied = true;
505 
506  $designConfig = $this->getDesignConfig();
507  $storeId = $designConfig->getStore();
508  $area = $designConfig->getArea();
509  if ($storeId !== null) {
510  // Force emulation in case email is being sent from same store so that theme will be loaded. Helpful
511  // for situations where emails may be sent from bootstrap files that load frontend store, but not theme
512  $this->appEmulation->startEnvironmentEmulation($storeId, $area, true);
513  }
514  return true;
515  }

◆ cancelDesignConfig()

cancelDesignConfig ( )
protected

Revert design settings to previous

Returns
$this

Definition at line 522 of file AbstractTemplate.php.

523  {
524  $this->appEmulation->stopEnvironmentEmulation();
525  $this->hasDesignBeenApplied = false;
526  return $this;
527  }

◆ emulateDesign()

emulateDesign (   $storeId,
  $area = self::DEFAULT_DESIGN_AREA 
)

Save current design config and replace with design config from specified store Event is not dispatched.

Parameters
null | bool | int | string$storeId
string$area
Returns
void

Definition at line 674 of file AbstractTemplate.php.

675  {
676  if ($storeId !== null && $storeId !== false) {
677  // save current design settings
678  $this->emulatedDesignConfig = clone $this->getDesignConfig();
679  if ($this->getDesignConfig()->getStore() != $storeId
680  || $this->getDesignConfig()->getArea() != $area
681  ) {
682  $this->setDesignConfig(['area' => $area, 'store' => $storeId]);
683  $this->applyDesignConfig();
684  }
685  } else {
686  $this->emulatedDesignConfig = false;
687  }
688  }

◆ getDefaultEmailLogo()

getDefaultEmailLogo ( )

Get default email logo image

Returns
string

Definition at line 371 of file AbstractTemplate.php.

372  {
373  $designParams = $this->getDesignParams();
374  return $this->assetRepo->getUrlWithParams(
375  self::DEFAULT_LOGO_FILE_ID,
376  $designParams
377  );
378  }

◆ getDesignConfig()

getDesignConfig ( )

Get design configuration data

Returns
DataObject

Definition at line 582 of file AbstractTemplate.php.

583  {
584  if ($this->designConfig === null) {
585  if ($this->area === null) {
586  $this->area = $this->design->getArea();
587  }
588  if ($this->store === null) {
589  $this->store = $this->storeManager->getStore()->getId();
590  }
591  $this->designConfig = new DataObject(
592  ['area' => $this->area, 'store' => $this->store]
593  );
594  }
595  return $this->designConfig;
596  }

◆ getDesignParams()

getDesignParams ( )

Returns the design params for the template being processed

Returns
array

Definition at line 565 of file AbstractTemplate.php.

566  {
567  return [
568  // Retrieve area from getDesignConfig, rather than the getDesignTheme->getArea(), as the latter doesn't
569  // return the emulated area
570  'area' => $this->getDesignConfig()->getArea(),
571  'theme' => $this->design->getDesignTheme()->getCode(),
572  'themeModel' => $this->design->getDesignTheme(),
573  'locale' => $this->design->getLocale(),
574  ];
575  }

◆ getFilterFactory()

getFilterFactory ( )
abstractprotected

Getter for filter factory that is specific to the type of template being processed

Returns
mixed

◆ getLogoAlt()

getLogoAlt (   $store)
protected

Return logo alt for emails

Parameters
Store | int | string$store
Returns
string

Definition at line 412 of file AbstractTemplate.php.

413  {
414  $store = $this->storeManager->getStore($store);
415  $alt = $this->scopeConfig->getValue(
416  self::XML_PATH_DESIGN_EMAIL_LOGO_ALT,
418  $store
419  );
420  if ($alt) {
421  return $alt;
422  }
423  return $store->getFrontendName();
424  }

◆ getLogoUrl()

getLogoUrl (   $store)
protected

Return logo URL for emails. Take logo from theme if custom logo is undefined

Parameters
Store | int | string$store
Returns
string

Definition at line 386 of file AbstractTemplate.php.

387  {
388  $store = $this->storeManager->getStore($store);
389  $fileName = $this->scopeConfig->getValue(
390  self::XML_PATH_DESIGN_EMAIL_LOGO,
392  $store
393  );
394  if ($fileName) {
396  $mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
397  if ($mediaDirectory->isFile($uploadDir . '/' . $fileName)) {
398  return $this->storeManager->getStore()->getBaseUrl(
399  \Magento\Framework\UrlInterface::URL_TYPE_MEDIA
400  ) . $uploadDir . '/' . $fileName;
401  }
402  }
403  return $this->getDefaultEmailLogo();
404  }
$fileName
Definition: translate.phtml:15
$mediaDirectory

◆ getProcessedTemplate()

getProcessedTemplate ( array  $variables = [])

Process email template code

Parameters
array$variables
Returns
string
Exceptions

Definition at line 328 of file AbstractTemplate.php.

329  {
330  $processor = $this->getTemplateFilter()
331  ->setUseSessionInUrl(false)
332  ->setPlainTemplateMode($this->isPlain())
333  ->setIsChildTemplate($this->isChildTemplate())
334  ->setTemplateProcessor([$this, 'getTemplateContent']);
335 
336  $variables['this'] = $this;
337 
338  $isDesignApplied = $this->applyDesignConfig();
339 
340  // Set design params so that CSS will be loaded from the proper theme
341  $processor->setDesignParams($this->getDesignParams());
342 
343  if (isset($variables['subscriber'])) {
344  $storeId = $variables['subscriber']->getStoreId();
345  } else {
346  $storeId = $this->getDesignConfig()->getStore();
347  }
348  $processor->setStoreId($storeId);
349 
350  // Populate the variables array with store, store info, logo, etc. variables
351  $variables = $this->addEmailVariables($variables, $storeId);
352  $processor->setVariables($variables);
353 
354  try {
355  $result = $processor->filter($this->getTemplateText());
356  } catch (\Exception $e) {
357  $this->cancelDesignConfig();
358  throw new \LogicException(__($e->getMessage()), $e->getCode(), $e);
359  }
360  if ($isDesignApplied) {
361  $this->cancelDesignConfig();
362  }
363  return $result;
364  }
$processor
Definition: 404.php:10
__()
Definition: __.php:13

◆ getTemplateContent()

getTemplateContent (   $configPath,
array  $variables 
)

Get contents of the included template for template directive

Parameters
string$configPath
array$variables
Returns
string

Definition at line 220 of file AbstractTemplate.php.

221  {
222  $template = $this->getTemplateInstance();
223 
224  // Ensure child templates have the same area/store context as parent
225  $template->setDesignConfig($this->getDesignConfig()->toArray())
226  ->loadByConfigPath($configPath, $variables)
227  ->setTemplateType($this->getType())
228  ->setIsChildTemplate(true);
229 
230  // automatically strip tags if in a plain-text parent
231  if ($this->isPlain()) {
232  $templateText = $this->filterManager->stripTags($template->getTemplateText());
233  $template->setTemplateText(trim($templateText));
234  }
235 
236  $processedTemplate = $template->getProcessedTemplate($variables);
237  if ($this->isPlain()) {
238  $processedTemplate = trim($processedTemplate);
239  }
240 
241  return $processedTemplate;
242  }
$template
Definition: export.php:12

◆ getTemplateFilter()

getTemplateFilter ( )

Get filter object for template processing

Returns
\Magento\Email\Model\Template\Filter

Definition at line 655 of file AbstractTemplate.php.

656  {
657  if (empty($this->templateFilter)) {
658  $this->templateFilter = $this->getFilterFactory()->create();
659  $this->templateFilter->setUseAbsoluteLinks($this->getUseAbsoluteLinks())
660  ->setStoreId($this->getDesignConfig()->getStore())
661  ->setUrlModel($this->urlModel);
662  }
663  return $this->templateFilter;
664  }

◆ getTemplateInstance()

getTemplateInstance ( )
protected

Return a new instance of the template object. Used by the template directive.

Returns
\Magento\Email\Model\AbstractTemplate

Definition at line 249 of file AbstractTemplate.php.

250  {
251  return $this->templateFactory->create();
252  }

◆ getType()

getType ( )
abstract

Getter for template type

Returns
int|string

Implements TemplateTypesInterface.

◆ getUrl()

getUrl ( Store  $store,
  $route = '',
  $params = [] 
)

Generate URL for the specified store.

Parameters
Store$store
string$route
array$params
Returns
string

Definition at line 736 of file AbstractTemplate.php.

737  {
738  $url = $this->urlModel->setScope($store);
739  if ($this->storeManager->getStore()->getId() != $store->getId()) {
740  $params['_scope_to_url'] = true;
741  }
742  return $url->getUrl($route, $params);
743  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ isChildTemplate()

isChildTemplate ( )

Check whether template is child of another template

Returns
bool

Definition at line 621 of file AbstractTemplate.php.

622  {
623  return $this->isChildTemplate;
624  }

◆ isPlain()

isPlain ( )

Return true if template type eq text

Returns
boolean

Implements TemplateTypesInterface.

Definition at line 709 of file AbstractTemplate.php.

◆ loadByConfigPath()

loadByConfigPath (   $configPath)

Load template from database when overridden in configuration or load default from relevant file system location.

Parameters
string$configPath
Returns
\Magento\Email\Model\AbstractTemplate

Definition at line 260 of file AbstractTemplate.php.

261  {
262  $store = $this->getDesignConfig()->getStore();
263  $templateId = $this->scopeConfig->getValue($configPath, ScopeInterface::SCOPE_STORE, $store);
264 
265  if (is_numeric($templateId)) {
266  $this->load($templateId);
267  } else {
268  $this->loadDefault($templateId);
269  }
270  return $this;
271  }
$templateId
Definition: queue.php:15

◆ loadDefault()

loadDefault (   $templateId)

Load default email template

Parameters
string$templateId
Returns
$this

trim copyright message

Definition at line 279 of file AbstractTemplate.php.

280  {
281  $designParams = $this->getDesignParams();
282  $templateFile = $this->emailConfig->getTemplateFilename($templateId, $designParams);
283  $templateType = $this->emailConfig->getTemplateType($templateId);
284  $templateTypeCode = $templateType == 'html' ? self::TYPE_HTML : self::TYPE_TEXT;
285  $this->setTemplateType($templateTypeCode);
286 
287  $rootDirectory = $this->filesystem->getDirectoryRead(DirectoryList::ROOT);
288  $templateText = $rootDirectory->readFile($rootDirectory->getRelativePath($templateFile));
289 
293  if (preg_match('/^<!--[\w\W]+?-->/m', $templateText, $matches) && strpos($matches[0], 'Copyright') !== false) {
294  $templateText = str_replace($matches[0], '', $templateText);
295  }
296 
297  if (preg_match('/<!--@subject\s*(.*?)\s*@-->/u', $templateText, $matches)) {
298  $this->setTemplateSubject($matches[1]);
299  $templateText = str_replace($matches[0], '', $templateText);
300  }
301 
302  if (preg_match('/<!--@vars\s*((?:.)*?)\s*@-->/us', $templateText, $matches)) {
303  $this->setData('orig_template_variables', str_replace("\n", '', $matches[1]));
304  $templateText = str_replace($matches[0], '', $templateText);
305  }
306 
307  if (preg_match('/<!--@styles\s*(.*?)\s*@-->/s', $templateText, $matches)) {
308  $this->setTemplateStyles($matches[1]);
309  $templateText = str_replace($matches[0], '', $templateText);
310  }
311 
312  // Remove comment lines and extra spaces
313  $templateText = trim(preg_replace('#\{\*.*\*\}#suU', '', $templateText));
314 
315  $this->setTemplateText($templateText);
316  $this->setId($templateId);
317 
318  return $this;
319  }
$templateType
Definition: list.phtml:37
$templateId
Definition: queue.php:15
$rootDirectory

◆ revertDesign()

revertDesign ( )

Revert to last design config, used before emulation

Returns
void

Definition at line 695 of file AbstractTemplate.php.

696  {
697  if ($this->emulatedDesignConfig) {
698  $this->setDesignConfig($this->emulatedDesignConfig->getData());
699  $this->cancelDesignConfig();
700  $this->emulatedDesignConfig = false;
701  }
702  }

◆ setDesignConfig()

setDesignConfig ( array  $config)

Initialize design information for template processing

Parameters
array$config
Returns
$this
Exceptions
LocalizedException

Definition at line 605 of file AbstractTemplate.php.

606  {
607  if (!isset($config['area']) || !isset($config['store'])) {
608  throw new LocalizedException(
609  __('The design config needs an area and a store. Verify that both are set and try again.')
610  );
611  }
612  $this->getDesignConfig()->setData($config);
613  return $this;
614  }
$config
Definition: fraud_order.php:17
__()
Definition: __.php:13

◆ setForcedArea()

setForcedArea (   $templateId)

Store the area associated with a template so that it will be returned by getDesignConfig and getDesignParams

Parameters
string$templateId
Returns
$this

Definition at line 535 of file AbstractTemplate.php.

536  {
537  if ($this->area === null) {
538  $this->area = $this->emailConfig->getTemplateArea($templateId);
539  }
540 
541  return $this;
542  }
$templateId
Definition: queue.php:15

◆ setForcedTheme()

setForcedTheme (   $templateId,
  $theme 
)

Manually set a theme that will be used by getParams

Used to force the loading of an email template from a specific theme

Parameters
string$templateId
string$theme
Returns
$this

Definition at line 553 of file AbstractTemplate.php.

554  {
555  $area = $this->emailConfig->getTemplateArea($templateId);
556  $this->design->setDesignTheme($theme, $area);
557  return $this;
558  }
$templateId
Definition: queue.php:15
$theme

◆ setIsChildTemplate()

setIsChildTemplate (   $isChildTemplate)

Set whether template is child of another template

Parameters
bool$isChildTemplate
Returns
$this

Definition at line 632 of file AbstractTemplate.php.

633  {
634  $this->isChildTemplate = (bool) $isChildTemplate;
635  return $this;
636  }

◆ setTemplateFilter()

setTemplateFilter ( Template\Filter  $filter)

Declare template processing filter

Parameters
\Magento\Email\Model\Template\Filter$filter
Returns
$this

Definition at line 644 of file AbstractTemplate.php.

645  {
646  $this->templateFilter = $filter;
647  return $this;
648  }

Field Documentation

◆ $appEmulation

$appEmulation
protected

Definition at line 125 of file AbstractTemplate.php.

◆ $assetRepo

$assetRepo
protected

Definition at line 137 of file AbstractTemplate.php.

◆ $design

$design = null
protected

Definition at line 120 of file AbstractTemplate.php.

◆ $emailConfig

$emailConfig
protected

Definition at line 154 of file AbstractTemplate.php.

◆ $filesystem

$filesystem
protected

Definition at line 142 of file AbstractTemplate.php.

◆ $filterManager

$filterManager
protected

Definition at line 159 of file AbstractTemplate.php.

◆ $scopeConfig

$scopeConfig
protected

Definition at line 149 of file AbstractTemplate.php.

◆ $storeManager

$storeManager
protected

Definition at line 130 of file AbstractTemplate.php.

◆ $templateFactory

$templateFactory = null
protected

Definition at line 113 of file AbstractTemplate.php.

◆ DEFAULT_DESIGN_AREA

const DEFAULT_DESIGN_AREA = 'frontend'

Default design area for emulation

Definition at line 32 of file AbstractTemplate.php.

◆ DEFAULT_LOGO_FILE_ID

const DEFAULT_LOGO_FILE_ID = 'Magento_Email::logo_email.png'

Default path to email logo

Definition at line 37 of file AbstractTemplate.php.

◆ XML_PATH_DESIGN_EMAIL_LOGO

const XML_PATH_DESIGN_EMAIL_LOGO = 'design/email/logo'

Email logo url

Definition at line 42 of file AbstractTemplate.php.

◆ XML_PATH_DESIGN_EMAIL_LOGO_ALT

const XML_PATH_DESIGN_EMAIL_LOGO_ALT = 'design/email/logo_alt'

Email logo alt text

Definition at line 47 of file AbstractTemplate.php.

◆ XML_PATH_DESIGN_EMAIL_LOGO_HEIGHT

const XML_PATH_DESIGN_EMAIL_LOGO_HEIGHT = 'design/email/logo_height'

Email logo height

Definition at line 57 of file AbstractTemplate.php.

◆ XML_PATH_DESIGN_EMAIL_LOGO_WIDTH

const XML_PATH_DESIGN_EMAIL_LOGO_WIDTH = 'design/email/logo_width'

Email logo width

Definition at line 52 of file AbstractTemplate.php.


The documentation for this class was generated from the following file: