@@ -146,6 +146,11 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn
146146 */
147147 protected $ emailConfig ;
148148
149+ /**
150+ * @var \Magento\Framework\UrlInterface
151+ */
152+ private $ urlModel ;
153+
149154 /**
150155 * @param \Magento\Framework\Model\Context $context
151156 * @param \Magento\Framework\View\DesignInterface $design
@@ -157,6 +162,7 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn
157162 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
158163 * @param Template\Config $emailConfig
159164 * @param \Magento\Email\Model\TemplateFactory $templateFactory
165+ * @param \Magento\Framework\Url $urlModel
160166 * @param array $data
161167 *
162168 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -172,6 +178,7 @@ public function __construct(
172178 \Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
173179 Template \Config $ emailConfig ,
174180 TemplateFactory $ templateFactory ,
181+ \Magento \Framework \UrlInterface $ urlModel ,
175182 array $ data = []
176183 ) {
177184 $ this ->design = $ design ;
@@ -184,6 +191,7 @@ public function __construct(
184191 $ this ->scopeConfig = $ scopeConfig ;
185192 $ this ->emailConfig = $ emailConfig ;
186193 $ this ->templateFactory = $ templateFactory ;
194+ $ this ->urlModel = $ urlModel ;
187195 parent ::__construct ($ context , $ registry , null , null , $ data );
188196 }
189197
@@ -645,11 +653,9 @@ public function getTemplateFilter()
645653 {
646654 if (empty ($ this ->templateFilter )) {
647655 $ this ->templateFilter = $ this ->getFilterFactory ()->create ();
648- $ this ->templateFilter ->setUseAbsoluteLinks (
649- $ this ->getUseAbsoluteLinks ()
650- )->setStoreId (
651- $ this ->getDesignConfig ()->getStore ()
652- );
656+ $ this ->templateFilter ->setUseAbsoluteLinks ($ this ->getUseAbsoluteLinks ())
657+ ->setStoreId ($ this ->getDesignConfig ()->getStore ())
658+ ->setUrlModel ($ this ->urlModel );
653659 }
654660 return $ this ->templateFilter ;
655661 }
@@ -716,4 +722,21 @@ abstract protected function getFilterFactory();
716722 * @return int|string
717723 */
718724 abstract public function getType ();
725+
726+ /**
727+ * Generate URL for the specified store.
728+ *
729+ * @param \Magento\Store\Model\Store $store
730+ * @param string $route
731+ * @param array $params
732+ * @return string
733+ */
734+ public function getUrl (\Magento \Store \Model \Store $ store , $ route = '' , $ params = [])
735+ {
736+ $ url = $ this ->urlModel ->setScope ($ store );
737+ if ($ this ->storeManager ->getStore ()->getId () != $ store ->getId ()) {
738+ $ params ['_scope_to_url ' ] = true ;
739+ }
740+ return $ url ->getUrl ($ route , $ params );
741+ }
719742}
0 commit comments