feat(legacy): add config dot notation access
This commit is contained in:
parent
f483852ccd
commit
e8785124e0
3 changed files with 85 additions and 17 deletions
|
@ -7,6 +7,7 @@ require_once __DIR__ . '/constants.php';
|
|||
require_once VENDOR_PATH . '/autoload.php';
|
||||
|
||||
// THIS FILE IS NOT MEANT FOR CUSTOMIZING.
|
||||
use Adbar\Dot;
|
||||
use League\Uri\Contracts\UriException;
|
||||
use League\Uri\Uri;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
|
@ -98,6 +99,7 @@ class Schema implements ConfigurationInterface
|
|||
class Config
|
||||
{
|
||||
private static $legacy_values;
|
||||
private static $dot_values;
|
||||
private static $values;
|
||||
|
||||
private static function load()
|
||||
|
@ -135,6 +137,7 @@ class Config
|
|||
|
||||
self::$values = $values;
|
||||
self::fillLegacyValues($values);
|
||||
self::$dot_values = new Dot($values);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,6 +159,33 @@ class Config
|
|||
}
|
||||
}
|
||||
|
||||
public static function get(...$args)
|
||||
{
|
||||
if (is_null(self::$dot_values)) self::load();
|
||||
return self::$dot_values->get(...$args);
|
||||
}
|
||||
|
||||
public static function has(...$args)
|
||||
{
|
||||
if (is_null(self::$dot_values)) self::load();
|
||||
return self::$dot_values->has(...$args);
|
||||
}
|
||||
|
||||
public static function getStoragePath()
|
||||
{
|
||||
return self::get('storage.path');
|
||||
}
|
||||
|
||||
public static function getPublicUrl()
|
||||
{
|
||||
return self::get('general.public_url');
|
||||
}
|
||||
|
||||
public static function getBasePath()
|
||||
{
|
||||
return self::get('general.public_url_raw')->getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy config
|
||||
*/
|
||||
|
@ -241,20 +271,4 @@ class Config
|
|||
|
||||
return self::$legacy_values;
|
||||
}
|
||||
|
||||
|
||||
public static function getStoragePath()
|
||||
{
|
||||
return self::getConfig()['storagePath'];
|
||||
}
|
||||
|
||||
public static function getPublicUrl()
|
||||
{
|
||||
return self::getConfig()['public_url'];
|
||||
}
|
||||
|
||||
public static function getBasePath()
|
||||
{
|
||||
return self::getConfig()['public_url_raw']->getPath();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue