mirror of
https://github.com/flarum/core.git
synced 2025-08-02 14:37:49 +02:00
Decouple from Laravel, implement translator
This commit is contained in:
88
framework/core/src/helpers.php
Normal file
88
framework/core/src/helpers.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Container\Container;
|
||||
|
||||
if (! function_exists('app')) {
|
||||
/**
|
||||
* Get the available container instance.
|
||||
*
|
||||
* @param string $make
|
||||
* @param array $parameters
|
||||
* @return mixed|\Illuminate\Foundation\Application
|
||||
*/
|
||||
function app($make = null, $parameters = [])
|
||||
{
|
||||
if (is_null($make)) {
|
||||
return Container::getInstance();
|
||||
}
|
||||
|
||||
return Container::getInstance()->make($make, $parameters);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
function base_path($path = '')
|
||||
{
|
||||
return app()->basePath().($path ? DIRECTORY_SEPARATOR.$path : $path);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('public_path')) {
|
||||
/**
|
||||
* Get the path to the public folder.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
function public_path($path = '')
|
||||
{
|
||||
return app()->make('path.public').($path ? DIRECTORY_SEPARATOR.$path : $path);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('storage_path')) {
|
||||
/**
|
||||
* Get the path to the storage folder.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
function storage_path($path = '')
|
||||
{
|
||||
return app('path.storage').($path ? DIRECTORY_SEPARATOR.$path : $path);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('event')) {
|
||||
/**
|
||||
* Fire an event and call the listeners.
|
||||
*
|
||||
* @param string|object $event
|
||||
* @param mixed $payload
|
||||
* @param bool $halt
|
||||
* @return array|null
|
||||
*/
|
||||
function event($event, $payload = [], $halt = false)
|
||||
{
|
||||
return app('events')->fire($event, $payload, $halt);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user