|
19 | 19 | use Magento\Framework\GraphQl\Config\Element\Field;
|
20 | 20 | use Magento\Framework\GraphQl\Query\EnumLookup;
|
21 | 21 | use Magento\Framework\GraphQl\Query\ResolverInterface;
|
| 22 | +use Magento\Framework\App\ObjectManager; |
| 23 | +use Magento\Framework\UrlInterface; |
22 | 24 |
|
23 | 25 | /**
|
24 | 26 | * @inheritdoc
|
@@ -47,22 +49,30 @@ class DownloadableOptions implements ResolverInterface
|
47 | 49 | */
|
48 | 50 | private $linkCollection;
|
49 | 51 |
|
| 52 | + /** |
| 53 | + * @var UrlInterface |
| 54 | + */ |
| 55 | + private $urlBuilder; |
| 56 | + |
50 | 57 | /**
|
51 | 58 | * @param EnumLookup $enumLookup
|
52 | 59 | * @param DownloadableHelper $downloadableHelper
|
53 | 60 | * @param SampleCollection $sampleCollection
|
54 | 61 | * @param LinkCollection $linkCollection
|
| 62 | + * @param UrlInterface|null $urlBuilder |
55 | 63 | */
|
56 | 64 | public function __construct(
|
57 | 65 | EnumLookup $enumLookup,
|
58 | 66 | DownloadableHelper $downloadableHelper,
|
59 | 67 | SampleCollection $sampleCollection,
|
60 |
| - LinkCollection $linkCollection |
| 68 | + LinkCollection $linkCollection, |
| 69 | + UrlInterface $urlBuilder = null |
61 | 70 | ) {
|
62 | 71 | $this->enumLookup = $enumLookup;
|
63 | 72 | $this->downloadableHelper = $downloadableHelper;
|
64 | 73 | $this->sampleCollection = $sampleCollection;
|
65 | 74 | $this->linkCollection = $linkCollection;
|
| 75 | + $this->urlBuilder = $urlBuilder ?: ObjectManager::getInstance()->get(UrlInterface::class); |
66 | 76 | }
|
67 | 77 |
|
68 | 78 | /**
|
@@ -165,7 +175,7 @@ private function formatSamples(Collection $samples) : array
|
165 | 175 | $resultData[$sampleKey]['sort_order'] = $sample->getSortOrder();
|
166 | 176 | $resultData[$sampleKey]['sample_type']
|
167 | 177 | = $this->enumLookup->getEnumValueFromField('DownloadableFileTypeEnum', $sample->getSampleType());
|
168 |
| - $resultData[$sampleKey]['sample_file'] = $sample->getSampleFile(); |
| 178 | + $resultData[$sampleKey]['sample_file'] = $this->urlBuilder->getUrl('downloadable/download/sample', ['sample_id' => $sample->getId()]); |
169 | 179 | $resultData[$sampleKey]['sample_url'] = $sample->getSampleUrl();
|
170 | 180 | }
|
171 | 181 | return $resultData;
|
|
0 commit comments