File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 22
33namespace craft \cloud \fs ;
44
5+ use craft \cloud \Helper ;
56use craft \cloud \Module ;
67use League \Uri \Contracts \SegmentedPathInterface ;
78
@@ -13,8 +14,12 @@ class AssetsFs extends Fs
1314
1415 public function init (): void
1516 {
16- $ this ->useLocalFs = !Module::getInstance ()->getConfig ()->useAssetCdn ;
1717 parent ::init ();
18+ $ this ->useLocalFs = !Module::getInstance ()->getConfig ()->useAssetCdn ;
19+
20+ if ($ this ->useLocalFs ) {
21+ $ this ->baseUrl = $ this ->getLocalFs ()->getRootUrl ();
22+ }
1823 }
1924
2025 /**
Original file line number Diff line number Diff line change 22
33namespace craft \cloud \fs ;
44
5+ use craft \cloud \Helper ;
56use craft \cloud \Module ;
67use League \Uri \Contracts \SegmentedPathInterface ;
78
89class BuildArtifactsFs extends BuildsFs
910{
1011 public bool $ hasUrls = true ;
12+ public ?string $ localFsPath = '@webroot ' ;
13+ public ?string $ localFsUrl = '@web ' ;
1114
1215 public function init (): void
1316 {
14- $ this ->baseUrl = Module::getInstance ()->getConfig ()->artifactBaseUrl ;
1517 parent ::init ();
18+ $ this ->useLocalFs = !Helper::isCraftCloud ();
19+ $ this ->baseUrl = Module::getInstance ()->getConfig ()->artifactBaseUrl ;
20+
21+ if ($ this ->useLocalFs && !$ this ->baseUrl ) {
22+ $ this ->baseUrl = $ this ->getLocalFs ()->getRootUrl ();
23+ }
1624 }
1725
1826 public function createBucketPrefix (): SegmentedPathInterface
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ protected function getLocalFs(): Local
7272 $ this ->localFs = $ this ->localFs ?? Craft::createObject ([
7373 'class ' => Local::class,
7474 'hasUrls ' => $ this ->hasUrls ,
75- 'path ' => $ path ->toString (),
75+ 'path ' => $ path? ->toString(),
7676 'url ' => $ this ->localFsUrl ,
7777 ]);
7878
@@ -93,10 +93,8 @@ public function getRootUrl(): ?string
9393
9494 public function createUrl (string $ path = '' ): UriInterface
9595 {
96- $ baseUrl = $ this ->useLocalFs ? $ this ->getLocalFs ()->getRootUrl () : $ this ->baseUrl ;
97-
98- if ($ baseUrl ) {
99- return Modifier::from ($ baseUrl )
96+ if ($ this ->baseUrl ) {
97+ return Modifier::from ($ this ->baseUrl )
10098 ->appendSegment ($ this ->createPath ($ path ))
10199 ->getUri ();
102100 }
You can’t perform that action at this time.
0 commit comments