-
Notifications
You must be signed in to change notification settings - Fork 9.4k
#1727: Introduce internal class wrapping SplFileInfo #29461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
magento-engcom-team
merged 7 commits into
magento:2.4-develop
from
joweecaquicla:1727-introduce-internal-class-wrapping-splfileinfo
Aug 19, 2020
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5a500f3
magento/adobe-stock-integration#1727: Introduce internal class wrappi…
bc24c44
Merge branch '2.4-develop' of github.com:magento/magento2 into 1727-i…
9f02257
magento/adobe-stock-integration#1727: Introduce internal class wrappi…
0b6ba91
magento/adobe-stock-integration#1727: Introduce internal class wrappi…
89e7f22
magento/adobe-stock-integration#1727: Introduce internal class wrappi…
beae26b
Fixed static test
sivaschenko 3752c1e
Merge branch '2.4-develop' into 1727-introduce-internal-class-wrappin…
sivaschenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
app/code/Magento/MediaGallerySynchronization/Model/Filesystem/FileInfo.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\MediaGallerySynchronization\Model\Filesystem; | ||
|
||
/** | ||
* Class for getting image file information. | ||
*/ | ||
class FileInfo | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $path; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $filename; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $extension; | ||
|
||
/** | ||
* @var $basename | ||
*/ | ||
private $basename; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $size; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $mTime; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $cTime; | ||
|
||
/** | ||
* FileInfo constructor. | ||
* | ||
* @param string $path | ||
* @param string $filename | ||
* @param string $extension | ||
* @param string $basename | ||
* @param int $size | ||
* @param int $mTime | ||
* @param int $cTime | ||
*/ | ||
public function __construct( | ||
string $path, | ||
string $filename, | ||
string $extension, | ||
string $basename, | ||
int $size, | ||
int $mTime, | ||
int $cTime | ||
) { | ||
$this->path = $path; | ||
$this->filename = $filename; | ||
$this->extension = $extension; | ||
$this->basename = $basename; | ||
$this->size = $size; | ||
$this->mTime = $mTime; | ||
$this->cTime = $cTime; | ||
} | ||
|
||
/** | ||
* Get path without filename. | ||
* | ||
* @return string | ||
*/ | ||
public function getPath(): string | ||
{ | ||
return $this->path; | ||
} | ||
|
||
/** | ||
* Get filename. | ||
* | ||
* @return string | ||
*/ | ||
public function getFilename(): string | ||
{ | ||
return $this->filename; | ||
} | ||
|
||
/** | ||
* Get file extension. | ||
* | ||
* @return string | ||
*/ | ||
public function getExtension(): string | ||
{ | ||
return $this->extension; | ||
} | ||
|
||
/** | ||
* Get file basename. | ||
* | ||
* @return string | ||
*/ | ||
public function getBasename(): string | ||
{ | ||
return $this->basename; | ||
} | ||
|
||
/** | ||
* Get file size. | ||
* | ||
* @return int | ||
*/ | ||
public function getSize(): int | ||
{ | ||
return $this->size; | ||
} | ||
|
||
/** | ||
* Get last modified time. | ||
* | ||
* @return int | ||
*/ | ||
public function getMTime(): int | ||
{ | ||
return $this->mTime; | ||
} | ||
|
||
/** | ||
* Get inode change time. | ||
* | ||
* @return int | ||
*/ | ||
public function getCTime(): int | ||
{ | ||
return $this->cTime; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
app/code/Magento/MediaGallerySynchronization/Model/Filesystem/GetFileInfo.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\MediaGallerySynchronization\Model\Filesystem; | ||
|
||
use Magento\MediaGallerySynchronization\Model\Filesystem\FileInfoFactory; | ||
|
||
/** | ||
* Get file information | ||
*/ | ||
class GetFileInfo | ||
{ | ||
/** | ||
* @var FileInfoFactory | ||
*/ | ||
private $fileInfoFactory; | ||
|
||
/** | ||
* GetFileInfo constructor. | ||
* @param FileInfoFactory $fileInfoFactory | ||
*/ | ||
public function __construct( | ||
FileInfoFactory $fileInfoFactory | ||
) { | ||
$this->fileInfoFactory = $fileInfoFactory; | ||
} | ||
|
||
/** | ||
* Get file information based on path provided. | ||
* | ||
* @param string $path | ||
* @return FileInfo | ||
*/ | ||
public function execute(string $path): FileInfo | ||
{ | ||
$splFileInfo = new \SplFileInfo($path); | ||
|
||
return $this->fileInfoFactory->create([ | ||
'path' => $splFileInfo->getPath(), | ||
'filename' => $splFileInfo->getFilename(), | ||
'extension' => $splFileInfo->getExtension(), | ||
'basename' => $splFileInfo->getBasename('.' . $splFileInfo->getExtension()), | ||
'size' => $splFileInfo->getSize(), | ||
'mTime' => $splFileInfo->getMTime(), | ||
'cTime' => $splFileInfo->getCTime() | ||
]); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.