-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #646 from magento-south/BUGS
[South] Bugs: - MAGETWO-56072 [Performance] Image resize mechanism does not generate images of all necessary sizes - MAGETWO-59904 [PR][Github] Update AccountLock.php #6952 - MAGETWO-53550 [Github][PR] Fix newsletter queue subscribers adding performance #4088 - MAGETWO-60047 [Porting] Error on adding address during checkout if add custom customer address attribute of file type - 2.2 - MAGETWO-56396 "Go Today" button in filter type date doesn`t apply value - MAGETWO-59365 Countries list is not loaded if change customer website after country was selected - MAGETWO-59924 File attribute doesn't have placeholder in admin
- Loading branch information
Showing
55 changed files
with
4,517 additions
and
2,625 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,107 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Catalog\Model\Category; | ||
|
||
use Magento\Framework\App\Filesystem\DirectoryList; | ||
use Magento\Framework\File\Mime; | ||
use Magento\Framework\Filesystem; | ||
use Magento\Framework\Filesystem\Directory\WriteInterface; | ||
|
||
/** | ||
* Class FileInfo | ||
* | ||
* Provides information about requested file | ||
*/ | ||
class FileInfo | ||
{ | ||
/** | ||
* Path in /pub/media directory | ||
*/ | ||
const ENTITY_MEDIA_PATH = '/catalog/category'; | ||
|
||
/** | ||
* @var Filesystem | ||
*/ | ||
private $filesystem; | ||
|
||
/** | ||
* @var Mime | ||
*/ | ||
private $mime; | ||
|
||
/** | ||
* @var WriteInterface | ||
*/ | ||
private $mediaDirectory; | ||
|
||
/** | ||
* @param Filesystem $filesystem | ||
* @param Mime $mime | ||
*/ | ||
public function __construct( | ||
Filesystem $filesystem, | ||
Mime $mime | ||
) { | ||
$this->filesystem = $filesystem; | ||
$this->mime = $mime; | ||
} | ||
|
||
/** | ||
* Get WriteInterface instance | ||
* | ||
* @return WriteInterface | ||
*/ | ||
private function getMediaDirectory() | ||
{ | ||
if ($this->mediaDirectory === null) { | ||
$this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); | ||
} | ||
return $this->mediaDirectory; | ||
} | ||
|
||
/** | ||
* Retrieve MIME type of requested file | ||
* | ||
* @param string $fileName | ||
* @return string | ||
*/ | ||
public function getMimeType($fileName) | ||
{ | ||
$filePath = self::ENTITY_MEDIA_PATH . '/' . ltrim($fileName, '/'); | ||
$absoluteFilePath = $this->getMediaDirectory()->getAbsolutePath($filePath); | ||
|
||
$result = $this->mime->getMimeType($absoluteFilePath); | ||
return $result; | ||
} | ||
|
||
/** | ||
* Get file statistics data | ||
* | ||
* @param string $fileName | ||
* @return array | ||
*/ | ||
public function getStat($fileName) | ||
{ | ||
$filePath = self::ENTITY_MEDIA_PATH . '/' . ltrim($fileName, '/'); | ||
|
||
$result = $this->getMediaDirectory()->stat($filePath); | ||
return $result; | ||
} | ||
|
||
/** | ||
* Check if the file exists | ||
* | ||
* @param string $fileName | ||
* @return bool | ||
*/ | ||
public function isExist($fileName) | ||
{ | ||
$filePath = self::ENTITY_MEDIA_PATH . '/' . ltrim($fileName, '/'); | ||
|
||
$result = $this->getMediaDirectory()->isExist($filePath); | ||
return $result; | ||
} | ||
} |
Oops, something went wrong.