|
7 | 7 |
|
8 | 8 | namespace Opengento\DocumentWidget\Block\Widget\Document; |
9 | 9 |
|
| 10 | +use Magento\Framework\Data\CollectionModifierInterface; |
10 | 11 | use Magento\Framework\DataObject\IdentityInterface; |
11 | 12 | use Magento\Framework\Exception\NoSuchEntityException; |
12 | 13 | use Magento\Framework\View\Element\Template; |
@@ -42,18 +43,25 @@ class ListByType extends Template implements BlockInterface, IdentityInterface |
42 | 43 | */ |
43 | 44 | private $imageViewModel; |
44 | 45 |
|
| 46 | + /** |
| 47 | + * @var CollectionModifierInterface |
| 48 | + */ |
| 49 | + private $collectionModifier; |
| 50 | + |
45 | 51 | public function __construct( |
46 | 52 | Context $context, |
47 | 53 | DocumentTypeRepositoryInterface $docTypeRepository, |
48 | 54 | CollectionFactory $collectionFactory, |
49 | 55 | UrlViewModel $urlViewModel, |
50 | 56 | ImageViewModel $imageViewModel, |
| 57 | + CollectionModifierInterface $collectionModifier, |
51 | 58 | array $data = [] |
52 | 59 | ) { |
53 | 60 | $this->docTypeRepository = $docTypeRepository; |
54 | 61 | $this->collectionFactory = $collectionFactory; |
55 | 62 | $this->urlViewModel = $urlViewModel; |
56 | 63 | $this->imageViewModel = $imageViewModel; |
| 64 | + $this->collectionModifier = $collectionModifier; |
57 | 65 | parent::__construct($context, $data); |
58 | 66 | } |
59 | 67 |
|
@@ -102,7 +110,7 @@ private function createCollection(): Collection |
102 | 110 | /** @var Collection $collection */ |
103 | 111 | $collection = $this->collectionFactory->create(); |
104 | 112 | $collection->addFieldToFilter('type_id', ['eq' => $this->getData('type_id')]); |
105 | | - $collection->addDefaultImage(); |
| 113 | + $this->collectionModifier->apply($collection); |
106 | 114 |
|
107 | 115 | return $collection; |
108 | 116 | } |
|
0 commit comments