改名
This commit is contained in:
@@ -10,6 +10,7 @@ declare(strict_types=1);
|
|||||||
namespace Snowflake\Abstracts;
|
namespace Snowflake\Abstracts;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Snowflake\Core\ArrayAccess;
|
||||||
use Snowflake\Exception\ConfigException;
|
use Snowflake\Exception\ConfigException;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ class Config extends Component
|
|||||||
if (empty($configs)) {
|
if (empty($configs)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$config->data = $configs;
|
$config->data = ArrayAccess::merge($config->data, $configs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+57
-18
@@ -17,35 +17,74 @@ class Runtime extends Command
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public string $command = 'runtime:builder';
|
public string $command = 'runtime:builder';
|
||||||
|
|
||||||
public string $description = 'create app file cache';
|
public string $description = 'create app file cache';
|
||||||
|
|
||||||
|
|
||||||
const CACHE_NAME = '.runtime.cache';
|
const CACHE_NAME = '.runtime.cache';
|
||||||
const CONFIG_NAME = '.config.cache';
|
const CONFIG_NAME = '.config.cache';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Input $dtl
|
* @param Input $dtl
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function onHandler(Input $dtl)
|
public function onHandler(Input $dtl)
|
||||||
{
|
{
|
||||||
// TODO: Implement onHandler() method.
|
// TODO: Implement onHandler() method.
|
||||||
$annotation = Snowflake::app()->getAnnotation();
|
$annotation = Snowflake::app()->getAnnotation();
|
||||||
|
|
||||||
$runtime = storage(static::CACHE_NAME);
|
$runtime = storage(static::CACHE_NAME);
|
||||||
|
|
||||||
$configs = Snowflake::app()->getConfig()->getData();
|
$configs = $this->configEach();
|
||||||
array_walk_recursive($configs, function (&$value, $key) {
|
|
||||||
if ($value instanceof \Closure) {
|
Snowflake::writeFile(storage(static::CONFIG_NAME), serialize($configs));
|
||||||
$value = null;
|
Snowflake::writeFile($runtime, serialize($annotation->getLoader()));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function configEach(): array
|
||||||
|
{
|
||||||
|
$array = [];
|
||||||
|
$configs = Snowflake::app()->getConfig();
|
||||||
|
foreach ($configs->getData() as $key => $datum) {
|
||||||
|
if ($datum instanceof \Closure) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (is_array($datum)) {
|
||||||
|
$array[$key] = $this->arrayEach($datum);
|
||||||
|
} else {
|
||||||
|
$array[$key] = $datum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $value
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function arrayEach(array $value): array
|
||||||
|
{
|
||||||
|
$array = [];
|
||||||
|
foreach ($value as $key => $item) {
|
||||||
|
if ($item instanceof \Closure) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (is_array($item)) {
|
||||||
|
$array[$key] = $this->arrayEach($item);
|
||||||
|
} else {
|
||||||
|
$array[$key] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
|
||||||
Snowflake::writeFile(storage(static::CONFIG_NAME), serialize($configs));
|
|
||||||
Snowflake::writeFile($runtime, serialize($annotation->getLoader()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user