mirror of
https://github.com/flarum/core.git
synced 2025-10-13 16:05:05 +02:00
Clean up usages / deprecate path helpers (#2155)
* Write source map without creating temp file Less I/O, and one less place where we access the global path helpers. * Drop useless app_path() helper This was probably taken straight from Laravel. There is no equivalent concept in Flarum, so this should be safe to remove. * Deprecate global path helpers Developers using these helpers can inject the `Paths` class instead. * Stop storing paths as strings in container * Avoid using path helpers from Application class * Deprecate path helpers from Application class * Avoid using public_path() in prerequisite check a) The comparison was already outdated, as a different path was passed. b) We're trying to get rid of these global helpers.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Foundation\Paths;
|
||||
use Illuminate\Container\Container;
|
||||
|
||||
if (! function_exists('app')) {
|
||||
@@ -27,29 +28,17 @@ if (! function_exists('app')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('app_path')) {
|
||||
/**
|
||||
* Get the path to the application folder.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
function app_path($path = '')
|
||||
{
|
||||
return app('path').($path ? DIRECTORY_SEPARATOR.$path : $path);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('base_path')) {
|
||||
/**
|
||||
* Get the path to the base of the install.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
* @deprecated Will be removed in Beta.15.
|
||||
*/
|
||||
function base_path($path = '')
|
||||
{
|
||||
return app()->basePath().($path ? DIRECTORY_SEPARATOR.$path : $path);
|
||||
return app(Paths::class)->base.($path ? DIRECTORY_SEPARATOR.$path : $path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,10 +48,11 @@ if (! function_exists('public_path')) {
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
* @deprecated Will be removed in Beta.15.
|
||||
*/
|
||||
function public_path($path = '')
|
||||
{
|
||||
return app()->publicPath().($path ? DIRECTORY_SEPARATOR.$path : $path);
|
||||
return app(Paths::class)->public.($path ? DIRECTORY_SEPARATOR.$path : $path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,10 +62,11 @@ if (! function_exists('storage_path')) {
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
* @deprecated Will be removed in Beta.15.
|
||||
*/
|
||||
function storage_path($path = '')
|
||||
{
|
||||
return app('path.storage').($path ? DIRECTORY_SEPARATOR.$path : $path);
|
||||
return app(Paths::class)->storage.($path ? DIRECTORY_SEPARATOR.$path : $path);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user