|
7 | 7 |
|
8 | 8 | namespace Magento\MediaGalleryRenditions\Model; |
9 | 9 |
|
10 | | -use Magento\MediaGallerySynchronizationApi\Api\ImportFileInterface; |
11 | | -use Magento\MediaGallerySynchronization\Model\Filesystem\SplFileInfoFactory; |
12 | | -use Magento\MediaGallerySynchronization\Model\CreateAssetFromFile; |
| 10 | +use Magento\Framework\Exception\LocalizedException; |
| 11 | +use Magento\MediaGallerySynchronization\Model\GetAssetFromPath; |
| 12 | +use Magento\MediaGallerySynchronizationApi\Model\ImportFilesInterface; |
13 | 13 | use Magento\MediaGalleryRenditionsApi\Api\GenerateRenditionsInterface; |
14 | 14 |
|
15 | 15 | /** |
16 | 16 | * Generate Rendition Images |
17 | 17 | */ |
18 | | -class GenerateRenditionImages implements ImportFileInterface |
| 18 | +class GenerateRenditionImages implements ImportFilesInterface |
19 | 19 | { |
20 | 20 | /** |
21 | | - * @var SplFileInfoFactory |
| 21 | + * @var GetAssetFromPath |
22 | 22 | */ |
23 | | - private $splFileInfoFactory; |
24 | | - |
25 | | - /** |
26 | | - * @var CreateAssetFromFile |
27 | | - */ |
28 | | - private $createAssetFromFile; |
| 23 | + private $getAssetFromPath; |
29 | 24 |
|
30 | 25 | /** |
31 | 26 | * @var GenerateRenditionsInterface |
32 | 27 | */ |
33 | 28 | private $generateRenditions; |
34 | 29 |
|
35 | 30 | /** |
36 | | - * @param SplFileInfoFactory $splFileInfoFactory |
37 | | - * @param CreateAssetFromFile $createAssetFromFile |
| 31 | + * @param GetAssetFromPath $getAssetFromPath |
38 | 32 | * @param GenerateRenditionsInterface $generateRenditions |
39 | 33 | */ |
40 | 34 | public function __construct( |
41 | | - SplFileInfoFactory $splFileInfoFactory, |
42 | | - CreateAssetFromFile $createAssetFromFile, |
| 35 | + GetAssetFromPath $getAssetFromPath, |
43 | 36 | GenerateRenditionsInterface $generateRenditions |
44 | 37 | ) { |
45 | | - $this->splFileInfoFactory = $splFileInfoFactory; |
46 | | - $this->createAssetFromFile = $createAssetFromFile; |
| 38 | + $this->getAssetFromPath = $getAssetFromPath; |
47 | 39 | $this->generateRenditions = $generateRenditions; |
48 | 40 | } |
49 | 41 |
|
50 | 42 | /** |
51 | | - * @inheritdoc |
| 43 | + * Save media files data |
| 44 | + * |
| 45 | + * @param string[] $paths |
| 46 | + * @throws LocalizedException |
52 | 47 | */ |
53 | | - public function execute(string $path): void |
| 48 | + public function execute(array $paths): void |
54 | 49 | { |
55 | | - $file = $this->splFileInfoFactory->create($path); |
56 | | - $this->generateRenditions->execute([$this->createAssetFromFile->execute($file)]); |
| 50 | + $assets = []; |
| 51 | + |
| 52 | + foreach ($paths as $path) { |
| 53 | + $assets[] = $this->getAssetFromPath->execute($path); |
| 54 | + } |
| 55 | + $this->generateRenditions->execute($assets); |
57 | 56 | } |
58 | 57 | } |
0 commit comments