39 private $mediaDirectory;
44 private $baseDirectory;
63 private function getMediaDirectory()
65 if ($this->mediaDirectory ===
null) {
68 return $this->mediaDirectory;
76 private function getBaseDirectory()
78 if (!isset($this->baseDirectory)) {
82 return $this->baseDirectory;
93 $filePath = $this->getFilePath(
$fileName);
94 $absoluteFilePath = $this->getMediaDirectory()->getAbsolutePath($filePath);
96 $result = $this->mime->getMimeType($absoluteFilePath);
108 $filePath = $this->getFilePath(
$fileName);
110 $result = $this->getMediaDirectory()->stat($filePath);
122 $filePath = $this->getFilePath(
$fileName);
124 $result = $this->getMediaDirectory()->isExist($filePath);
138 $mediaDirectoryRelativeSubpath = $this->getMediaDirectoryPathRelativeToBaseDirectoryPath();
142 $fileIsInCategoryMediaDir = !$isFileNameBeginsWithMediaDirectoryPath;
144 if ($fileIsInCategoryMediaDir) {
145 $filePath = self::ENTITY_MEDIA_PATH .
'/' . $filePath;
147 $filePath = substr($filePath, strlen($mediaDirectoryRelativeSubpath));
163 $mediaDirectoryRelativeSubpath = $this->getMediaDirectoryPathRelativeToBaseDirectoryPath();
164 $isFileNameBeginsWithMediaDirectoryPath = strpos($filePath, $mediaDirectoryRelativeSubpath) === 0;
166 return $isFileNameBeginsWithMediaDirectoryPath;
174 private function getMediaDirectoryPathRelativeToBaseDirectoryPath()
176 $baseDirectoryPath = $this->getBaseDirectory()->getAbsolutePath();
177 $mediaDirectoryPath = $this->getMediaDirectory()->getAbsolutePath();
179 $mediaDirectoryRelativeSubpath = substr($mediaDirectoryPath, strlen($baseDirectoryPath));
181 return $mediaDirectoryRelativeSubpath;
__construct(Filesystem $filesystem, Mime $mime)
isBeginsWithMediaDirectoryPath($fileName)