Skip to content

Commit 5a500f3

Browse files
author
joweecaquicla
committed
magento/adobe-stock-integration#1727: Introduce internal class wrapping SplFileInfo - implement class wrapping SplFileInfo and modified the files to use the newly added classes
1 parent 237c2b1 commit 5a500f3

File tree

5 files changed

+374
-24
lines changed

5 files changed

+374
-24
lines changed

app/code/Magento/MediaGallerySynchronization/Model/CreateAssetFromFile.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
1717
use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory;
1818
use Magento\MediaGalleryMetadataApi\Api\ExtractMetadataInterface;
19-
use Magento\MediaGallerySynchronization\Model\Filesystem\SplFileInfoFactory;
19+
use Magento\MediaGallerySynchronization\Model\Filesystem\GetFileInfo;
2020
use Magento\MediaGallerySynchronization\Model\GetContentHash;
2121

2222
/**
@@ -60,9 +60,9 @@ class CreateAssetFromFile
6060
private $extractMetadata;
6161

6262
/**
63-
* @var SplFileInfoFactory
63+
* @var GetFileInfo
6464
*/
65-
private $splFileInfoFactory;
65+
private $getFileInfo;
6666

6767
/**
6868
* @param Filesystem $filesystem
@@ -71,7 +71,7 @@ class CreateAssetFromFile
7171
* @param AssetInterfaceFactory $assetFactory
7272
* @param GetContentHash $getContentHash
7373
* @param ExtractMetadataInterface $extractMetadata
74-
* @param SplFileInfoFactory $splFileInfoFactory
74+
* @param GetFileInfo $getFileInfo
7575
*/
7676
public function __construct(
7777
Filesystem $filesystem,
@@ -80,15 +80,15 @@ public function __construct(
8080
AssetInterfaceFactory $assetFactory,
8181
GetContentHash $getContentHash,
8282
ExtractMetadataInterface $extractMetadata,
83-
SplFileInfoFactory $splFileInfoFactory
83+
GetFileInfo $getFileInfo
8484
) {
8585
$this->filesystem = $filesystem;
8686
$this->driver = $driver;
8787
$this->date = $date;
8888
$this->assetFactory = $assetFactory;
8989
$this->getContentHash = $getContentHash;
9090
$this->extractMetadata = $extractMetadata;
91-
$this->splFileInfoFactory = $splFileInfoFactory;
91+
$this->getFileInfo = $getFileInfo;
9292
}
9393

9494
/**
@@ -101,7 +101,7 @@ public function __construct(
101101
public function execute(string $path): AssetInterface
102102
{
103103
$absolutePath = $this->getMediaDirectory()->getAbsolutePath($path);
104-
$file = $this->splFileInfoFactory->create($absolutePath);
104+
$file = $this->getFileInfo->execute($absolutePath);
105105
[$width, $height] = getimagesize($absolutePath);
106106

107107
$metadata = $this->extractMetadata->execute($absolutePath);
Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\MediaGallerySynchronization\Model\Filesystem;
9+
10+
/**
11+
* Class FileInfo
12+
*/
13+
class FileInfo extends \SplFileInfo
14+
{
15+
/**
16+
* @var string
17+
*/
18+
private $path;
19+
20+
/**
21+
* @var string
22+
*/
23+
private $filename;
24+
25+
/**
26+
* @var string
27+
*/
28+
private $extension;
29+
30+
/**
31+
* @var $basename
32+
*/
33+
private $basename;
34+
35+
/**
36+
* @var string
37+
*/
38+
private $pathname;
39+
40+
/**
41+
* @var int
42+
*/
43+
private $perms;
44+
45+
/**
46+
* @var int
47+
*/
48+
private $inode;
49+
50+
/**
51+
* @var int
52+
*/
53+
private $size;
54+
55+
/**
56+
* @var int
57+
*/
58+
private $owner;
59+
60+
/**
61+
* @var int
62+
*/
63+
private $group;
64+
65+
/**
66+
* @var int
67+
*/
68+
private $aTime;
69+
70+
/**
71+
* @var int
72+
*/
73+
private $mTime;
74+
75+
/**
76+
* @var int
77+
*/
78+
private $cTime;
79+
80+
/**
81+
* @var string
82+
*/
83+
private $type;
84+
85+
/**
86+
* @var false|string
87+
*/
88+
private $realPath;
89+
90+
/**
91+
* @var \SplFileInfo
92+
*/
93+
private $fileInfo;
94+
95+
/**
96+
* @var \SplFileInfo
97+
*/
98+
private $pathInfo;
99+
100+
/**
101+
* FileInfo constructor.
102+
* @param string $file_name
103+
* @param string $path
104+
* @param string $filename
105+
* @param string $extension
106+
* @param string $basename
107+
* @param string $pathname
108+
* @param int $perms
109+
* @param int $inode
110+
* @param int $size
111+
* @param int $owner
112+
* @param int $group
113+
* @param int $aTime
114+
* @param int $mTime
115+
* @param int $cTime
116+
* @param string $type
117+
* @param false|string $realPath
118+
* @param \SplFileInfo $fileInfo
119+
* @param \SplFileInfo $pathInfo
120+
*/
121+
public function __construct(
122+
string $file_name,
123+
string $path,
124+
string $filename,
125+
string $extension,
126+
string $basename,
127+
string $pathname,
128+
int $perms,
129+
int $inode,
130+
int $size,
131+
int $owner,
132+
int $group,
133+
int $aTime,
134+
int $mTime,
135+
int $cTime,
136+
string $type,
137+
$realPath,
138+
\SplFileInfo $fileInfo,
139+
\SplFileInfo $pathInfo
140+
) {
141+
parent::__construct($file_name);
142+
$this->path = $path;
143+
$this->filename = $filename;
144+
$this->extension = $extension;
145+
$this->basename = $basename;
146+
$this->pathname = $pathname;
147+
$this->perms = $perms;
148+
$this->inode = $inode;
149+
$this->size = $size;
150+
$this->owner = $owner;
151+
$this->group = $group;
152+
$this->aTime = $aTime;
153+
$this->mTime = $mTime;
154+
$this->cTime = $cTime;
155+
$this->type = $type;
156+
$this->realPath = $realPath;
157+
$this->fileInfo = $fileInfo;
158+
$this->pathInfo = $pathInfo;
159+
}
160+
161+
/**
162+
* @inheritDoc
163+
*/
164+
public function getPath(): string
165+
{
166+
return $this->path;
167+
}
168+
169+
/**
170+
* @inheritDoc
171+
*/
172+
public function getFilename(): string
173+
{
174+
return $this->filename;
175+
}
176+
177+
/**
178+
* @inheritDoc
179+
*/
180+
public function getExtension(): string
181+
{
182+
return $this->extension;
183+
}
184+
185+
/**
186+
* @inheritDoc
187+
*/
188+
public function getBasename($suffix = null): string
189+
{
190+
return $this->basename;
191+
}
192+
193+
/**
194+
* @inheritDoc
195+
*/
196+
public function getPathname(): string
197+
{
198+
return $this->pathname;
199+
}
200+
201+
/**
202+
* @inheritDoc
203+
*/
204+
public function getPerms(): int
205+
{
206+
return $this->perms;
207+
}
208+
209+
/**
210+
* @inheritDoc
211+
*/
212+
public function getInode(): int
213+
{
214+
return $this->inode;
215+
}
216+
217+
/**
218+
* @inheritDoc
219+
*/
220+
public function getSize(): int
221+
{
222+
return $this->size;
223+
}
224+
225+
/**
226+
* @inheritDoc
227+
*/
228+
public function getOwner(): int
229+
{
230+
return $this->owner;
231+
}
232+
233+
/**
234+
* @inheritDoc
235+
*/
236+
public function getGroup(): int
237+
{
238+
return $this->group;
239+
}
240+
241+
/**
242+
* @inheritDoc
243+
*/
244+
public function getATime(): int
245+
{
246+
return $this->aTime;
247+
}
248+
249+
/**
250+
* @inheritDoc
251+
*/
252+
public function getMTime(): int
253+
{
254+
return $this->mTime;
255+
}
256+
257+
/**
258+
* @inheritDoc
259+
*/
260+
public function getCTime(): int
261+
{
262+
return $this->cTime;
263+
}
264+
265+
/**
266+
* @inheritDoc
267+
*/
268+
public function getType(): string
269+
{
270+
return $this->type;
271+
}
272+
273+
/**
274+
* @inheritDoc
275+
*/
276+
public function getRealPath()
277+
{
278+
return $this->realPath;
279+
}
280+
281+
/**
282+
* @inheritDoc
283+
*/
284+
public function getFileInfo($class_name = null): \SplFileInfo
285+
{
286+
return $this->fileInfo;
287+
}
288+
289+
/**
290+
* @inheritDoc
291+
*/
292+
public function getPathInfo($class_name = null): \SplFileInfo
293+
{
294+
return $this->pathInfo;
295+
}
296+
}

0 commit comments

Comments
 (0)