File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -86,4 +86,29 @@ public static function fixFilePath(string $path): string
8686 {
8787 return str_replace (['\\' , '// ' ], '/ ' , $ path );
8888 }
89+
90+ public static function resolveFilePath (string $ filePath ): string {
91+ if (self ::isUrl ($ filePath )) {
92+ return $ filePath ;
93+ }
94+
95+ if (!self ::isAbsolutePath ($ filePath )) {
96+ $ filePath = self ::getAbsolutePath ($ filePath );
97+ }
98+
99+ if (file_exists ($ filePath )) {
100+ return $ filePath ;
101+ }
102+
103+ $ altPath1 = $ _SERVER ['DOCUMENT_ROOT ' ] . $ filePath ;
104+ $ altPath2 = $ _SERVER ['DOCUMENT_ROOT ' ] . '/ ' . $ filePath ;
105+
106+ if (file_exists ($ altPath1 )) {
107+ return $ altPath1 ;
108+ } elseif (file_exists ($ altPath2 )) {
109+ return $ altPath2 ;
110+ }
111+
112+ throw new Exception ('File not found: ' . $ filePath );
113+ }
89114}
You can’t perform that action at this time.
0 commit comments