@@ -58,25 +58,26 @@ abstract class AbstractEmail extends \Magento\Framework\View\Element\Template
58
58
59
59
/**
60
60
* @param \Magento\Framework\View\Element\Template\Context $context
61
- * @param \Magento\Framework\Filter\Input\MaliciousCode $maliciousCode
62
- * @param PriceCurrencyInterface $priceCurrency
63
- * @param \Magento\Catalog\Block\Product\ImageBuilder $imageBuilder
64
- * @param \Magento\Store\Model\App\Emulation $appEmulation
65
- * @param array $data
61
+ * @param \Magento\Framework\Filter\Input\MaliciousCode $maliciousCode
62
+ * @param PriceCurrencyInterface $priceCurrency
63
+ * @param \Magento\Catalog\Block\Product\ImageBuilder $imageBuilder
64
+ * @param array $data
65
+ * @param \Magento\Store\Model\App\Emulation $appEmulation
66
66
*/
67
67
public function __construct (
68
68
\Magento \Framework \View \Element \Template \Context $ context ,
69
69
\Magento \Framework \Filter \Input \MaliciousCode $ maliciousCode ,
70
70
PriceCurrencyInterface $ priceCurrency ,
71
71
\Magento \Catalog \Block \Product \ImageBuilder $ imageBuilder ,
72
- \ Magento \ Store \ Model \ App \ Emulation $ appEmulation ,
73
- array $ data = []
72
+ array $ data = [] ,
73
+ \ Magento \ Store \ Model \ App \ Emulation $ appEmulation = null
74
74
) {
75
75
$ this ->imageBuilder = $ imageBuilder ;
76
76
$ this ->priceCurrency = $ priceCurrency ;
77
77
$ this ->_maliciousCode = $ maliciousCode ;
78
- $ this ->appEmulation = $ appEmulation ;
79
78
$ this ->storeManager = $ context ->getStoreManager ();
79
+ $ this ->appEmulation = $ appEmulation
80
+ ?: \Magento \Framework \App \ObjectManager::getInstance ()->get (\Magento \Store \Model \App \Emulation::class);
80
81
81
82
parent ::__construct ($ context , $ data );
82
83
}
@@ -229,11 +230,11 @@ public function getProductPriceHtml(
229
230
/**
230
231
* Retrieve product image.
231
232
*
232
- * @param $product
233
- * @param $imageId
233
+ * @param \Magento\Catalog\Model\Product $product
234
+ * @param string $imageId
234
235
* @param array $attributes
235
- *
236
236
* @return \Magento\Catalog\Block\Product\Image
237
+ * @throws \Exception
237
238
*/
238
239
public function getImage ($ product , $ imageId , $ attributes = [])
239
240
{
@@ -243,10 +244,15 @@ public function getImage($product, $imageId, $attributes = [])
243
244
true
244
245
);
245
246
246
- $ image = $ this ->imageBuilder ->setProduct ($ product )
247
- ->setImageId ($ imageId )
248
- ->setAttributes ($ attributes )
249
- ->create ();
247
+ try {
248
+ $ image = $ this ->imageBuilder ->setProduct ($ product )
249
+ ->setImageId ($ imageId )
250
+ ->setAttributes ($ attributes )
251
+ ->create ();
252
+ } catch (\Exception $ e ) {
253
+ $ this ->appEmulation ->stopEnvironmentEmulation ();
254
+ throw $ e ;
255
+ }
250
256
251
257
$ this ->appEmulation ->stopEnvironmentEmulation ();
252
258
0 commit comments