feat(legacy): add config dot notation access
This commit is contained in:
parent
f483852ccd
commit
e8785124e0
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"adbario/php-dot-notation": "^2.3.0",
|
||||
"composer/semver": "^3.2",
|
||||
"james-heinrich/getid3": "^1.9",
|
||||
"jooola/celery-php": "dev-master",
|
||||
|
|
|
@ -4,8 +4,61 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "ae64767078beb8eada6d1c6b98f349ad",
|
||||
"content-hash": "5fa10b8427129984dd981839ea8b1d70",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adbario/php-dot-notation",
|
||||
"version": "2.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/adbario/php-dot-notation.git",
|
||||
"reference": "39ece8d385ce2f5e03718c693932d83ab0cb5972"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/adbario/php-dot-notation/zipball/39ece8d385ce2f5e03718c693932d83ab0cb5972",
|
||||
"reference": "39ece8d385ce2f5e03718c693932d83ab0cb5972",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": "^5.5 || ^7.0 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5",
|
||||
"squizlabs/php_codesniffer": "^3.6"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Adbar\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Riku Särkinen",
|
||||
"email": "riku@adbar.io"
|
||||
}
|
||||
],
|
||||
"description": "PHP dot notation access to arrays",
|
||||
"homepage": "https://github.com/adbario/php-dot-notation",
|
||||
"keywords": [
|
||||
"ArrayAccess",
|
||||
"dotnotation"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/adbario/php-dot-notation/issues",
|
||||
"source": "https://github.com/adbario/php-dot-notation/tree/2.3.0"
|
||||
},
|
||||
"time": "2022-07-12T02:52:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/semver",
|
||||
"version": "3.3.2",
|
||||
|
|
Loading…
Reference in New Issue