Skip to content

Commit 9aa1f66

Browse files
committed
Move method logic to new code location
1 parent beaf511 commit 9aa1f66

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

packages/framework/src/Foundation/Kernel/Filesystem.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Hyde\Hyde;
88
use Hyde\Foundation\HydeKernel;
99
use Hyde\Foundation\PharSupport;
10+
use Hyde\Support\Filesystem\MediaFile;
1011
use Illuminate\Support\Collection;
1112

1213
use function collect;
@@ -96,11 +97,7 @@ public function pathToRelative(string $path): string
9697
*/
9798
public function mediaPath(string $path = ''): string
9899
{
99-
if (empty($path)) {
100-
return Hyde::path(Hyde::getMediaDirectory());
101-
}
102-
103-
return Hyde::path(path_join(Hyde::getMediaDirectory(), unslash($path)));
100+
return MediaFile::sourcePath($path);
104101
}
105102

106103
/**
@@ -120,13 +117,7 @@ public function sitePath(string $path = ''): string
120117
*/
121118
public function siteMediaPath(string $path = ''): string
122119
{
123-
if (empty($path)) {
124-
return Hyde::sitePath(Hyde::getMediaOutputDirectory());
125-
}
126-
127-
$path = unslash($path);
128-
129-
return Hyde::sitePath(Hyde::getMediaOutputDirectory()."/$path");
120+
return MediaFile::outputPath($path);
130121
}
131122

132123
/**

packages/framework/src/Support/Filesystem/MediaFile.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
use Hyde\Hyde;
88
use Hyde\Facades\Config;
9-
use Hyde\Foundation\HydeKernel;
109
use Hyde\Framework\Exceptions\FileNotFoundException;
1110
use Illuminate\Support\Str;
1211

12+
use function Hyde\unslash;
13+
use function Hyde\path_join;
1314
use function extension_loaded;
1415
use function file_exists;
1516
use function array_merge;
@@ -47,15 +48,25 @@ public static function files(): array
4748
*/
4849
public static function sourcePath(string $path = ''): string
4950
{
50-
return HydeKernel::getInstance()->mediaPath($path);
51+
if (empty($path)) {
52+
return Hyde::path(Hyde::getMediaDirectory());
53+
}
54+
55+
return Hyde::path(path_join(Hyde::getMediaDirectory(), unslash($path)));
5156
}
5257

5358
/**
5459
* Get the absolute path to the compiled site's media directory, or a file within it.
5560
*/
5661
public static function outputPath(string $path = ''): string
5762
{
58-
return HydeKernel::getInstance()->siteMediaPath($path);
63+
if (empty($path)) {
64+
return Hyde::sitePath(Hyde::getMediaOutputDirectory());
65+
}
66+
67+
$path = unslash($path);
68+
69+
return Hyde::sitePath(Hyde::getMediaOutputDirectory()."/$path");
5970
}
6071

6172
public function getIdentifier(): string

0 commit comments

Comments
 (0)