Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

[BugFix] Fix area for image placeholder in graphql response. #364

Prev Previous commit
Next Next commit
graphQl-239: removed creating assets
  • Loading branch information
Vitaliy Boyko committed Feb 21, 2019
commit 6c3440124dbe4d206dc7c9b70719f3579b6a2038
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@

namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Image;

use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Image\Placeholder\Theme;
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
use Magento\Framework\View\Asset\Repository as AssetRepository;

@@ -26,33 +25,24 @@ class Placeholder
*/
private $assetRepository;

/**
* @var Theme
*/
private $theme;

/**
* Placeholder constructor.
* @param PlaceholderFactory $placeholderFactory
* @param AssetRepository $assetRepository
* @param Theme $theme
*/
public function __construct(
PlaceholderFactory $placeholderFactory,
AssetRepository $assetRepository,
Theme $theme
AssetRepository $assetRepository
) {
$this->placeholderFactory = $placeholderFactory;
$this->assetRepository = $assetRepository;
$this->theme = $theme;
}

/**
* Get placeholder
*
* @param string $imageType
* @return string
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function getPlaceholder(string $imageType): string
{
@@ -63,10 +53,8 @@ public function getPlaceholder(string $imageType): string
return $imageAsset->getUrl();
}

$themeData = $this->theme->getThemeData();
return $this->assetRepository->createAsset(
"Magento_Catalog::images/product/placeholder/{$imageType}.jpg",
$themeData
)->getUrl();
return $this->assetRepository->getUrl(
"Magento_Catalog::images/product/placeholder/{$imageType}.jpg"
);
}
}