Revert "改名"
This reverts commit fdf58326
This commit is contained in:
@@ -23,15 +23,15 @@ class Config extends Component
|
|||||||
|
|
||||||
const ERROR_MESSAGE = 'The not find %s in app configs.';
|
const ERROR_MESSAGE = 'The not find %s in app configs.';
|
||||||
|
|
||||||
protected mixed $data = [];
|
protected static mixed $data = [];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getData(): mixed
|
public static function getData(): mixed
|
||||||
{
|
{
|
||||||
return $this->data;
|
return static::$data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -40,23 +40,21 @@ class Config extends Component
|
|||||||
* @param $value
|
* @param $value
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function setData($key, $value): mixed
|
public static function setData($key, $value): mixed
|
||||||
{
|
{
|
||||||
return $this->data[$key] = $value;
|
return static::$data[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $configs
|
* @param array $configs
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public static function sets(array $configs)
|
public static function sets(array $configs)
|
||||||
{
|
{
|
||||||
$config = Kiri::app()->getConfig();
|
|
||||||
if (empty($configs)) {
|
if (empty($configs)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$config->data = $configs;
|
static::$data = $configs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,11 +62,11 @@ class Config extends Component
|
|||||||
* @param bool $try
|
* @param bool $try
|
||||||
* @param mixed|null $default
|
* @param mixed|null $default
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws
|
* @throws ConfigException
|
||||||
*/
|
*/
|
||||||
public static function get($key, mixed $default = null, bool $try = FALSE): mixed
|
public static function get($key, mixed $default = null, bool $try = FALSE): mixed
|
||||||
{
|
{
|
||||||
$instance = Kiri::app()->getConfig()->getData();
|
$instance = static::$data;
|
||||||
if (!str_contains($key, '.')) {
|
if (!str_contains($key, '.')) {
|
||||||
return $instance[$key] ?? $default;
|
return $instance[$key] ?? $default;
|
||||||
}
|
}
|
||||||
@@ -94,27 +92,23 @@ class Config extends Component
|
|||||||
* @param $key
|
* @param $key
|
||||||
* @param $value
|
* @param $value
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public static function set($key, $value): mixed
|
public static function set($key, $value): mixed
|
||||||
{
|
{
|
||||||
$config = Kiri::app()->getConfig();
|
return static::setData($key, $value);
|
||||||
return $config->setData($key, $value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $key
|
* @param $key
|
||||||
* @param bool $must_not_null
|
* @param bool $must_not_null
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public static function has($key, bool $must_not_null = false): bool
|
public static function has($key, bool $must_not_null = false): bool
|
||||||
{
|
{
|
||||||
$config = Kiri::app()->getConfig();
|
if (!isset(static::$data[$key])) {
|
||||||
if (!isset($config->data[$key])) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$config = $config->data[$key];
|
$config = static::$data[$key];
|
||||||
if ($must_not_null === false) {
|
if ($must_not_null === false) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Kiri;
|
|||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Abstracts\Input;
|
use Kiri\Abstracts\Input;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
@@ -62,8 +63,7 @@ class Runtime extends Command
|
|||||||
public function configEach(): string
|
public function configEach(): string
|
||||||
{
|
{
|
||||||
$array = [];
|
$array = [];
|
||||||
$configs = Kiri::app()->getConfig();
|
foreach (Config::getData() as $key => $datum) {
|
||||||
foreach ($configs->getData() as $key => $datum) {
|
|
||||||
if ($datum instanceof \Closure) {
|
if ($datum instanceof \Closure) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user