Skip to content

Commit 28e6421

Browse files
author
Jeroen van Leusden
committed
Format code according specifications
1 parent a9e2db7 commit 28e6421

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,26 @@ abstract class AbstractEmail extends \Magento\Framework\View\Element\Template
5858

5959
/**
6060
* @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
6666
*/
6767
public function __construct(
6868
\Magento\Framework\View\Element\Template\Context $context,
6969
\Magento\Framework\Filter\Input\MaliciousCode $maliciousCode,
7070
PriceCurrencyInterface $priceCurrency,
7171
\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
7474
) {
7575
$this->imageBuilder = $imageBuilder;
7676
$this->priceCurrency = $priceCurrency;
7777
$this->_maliciousCode = $maliciousCode;
78-
$this->appEmulation = $appEmulation;
7978
$this->storeManager = $context->getStoreManager();
79+
$this->appEmulation = $appEmulation
80+
?: \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Store\Model\App\Emulation::class);
8081

8182
parent::__construct($context, $data);
8283
}
@@ -229,11 +230,11 @@ public function getProductPriceHtml(
229230
/**
230231
* Retrieve product image.
231232
*
232-
* @param $product
233-
* @param $imageId
233+
* @param \Magento\Catalog\Model\Product $product
234+
* @param string $imageId
234235
* @param array $attributes
235-
*
236236
* @return \Magento\Catalog\Block\Product\Image
237+
* @throws \Exception
237238
*/
238239
public function getImage($product, $imageId, $attributes = [])
239240
{
@@ -243,10 +244,15 @@ public function getImage($product, $imageId, $attributes = [])
243244
true
244245
);
245246

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+
}
250256

251257
$this->appEmulation->stopEnvironmentEmulation();
252258

0 commit comments

Comments
 (0)