改名
This commit is contained in:
+26
-15
@@ -4,6 +4,7 @@ defined('APP_PATH') or define('APP_PATH', realpath(__DIR__ . '/../../'));
|
|||||||
|
|
||||||
|
|
||||||
use Annotation\Annotation;
|
use Annotation\Annotation;
|
||||||
|
use Annotation\Route\Route;
|
||||||
use Http\Handler\Router;
|
use Http\Handler\Router;
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
@@ -14,10 +15,8 @@ use Kiri\Error\Logger;
|
|||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Events\EventProvider;
|
use Kiri\Events\EventProvider;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Exception\NotFindClassException;
|
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Server\ServerManager;
|
|
||||||
use Swoole\Process;
|
use Swoole\Process;
|
||||||
use Swoole\WebSocket\Server;
|
use Swoole\WebSocket\Server;
|
||||||
|
|
||||||
@@ -227,6 +226,8 @@ if (!function_exists('injectRuntime')) {
|
|||||||
{
|
{
|
||||||
$fileLists = Kiri::getAnnotation()->runtime($path, $exclude);
|
$fileLists = Kiri::getAnnotation()->runtime($path, $exclude);
|
||||||
$di = Kiri::getDi();
|
$di = Kiri::getDi();
|
||||||
|
|
||||||
|
$router = [];
|
||||||
foreach ($fileLists as $class) {
|
foreach ($fileLists as $class) {
|
||||||
foreach (NoteManager::getTargetNote($class) as $value) {
|
foreach (NoteManager::getTargetNote($class) as $value) {
|
||||||
$value->execute($class);
|
$value->execute($class);
|
||||||
@@ -237,10 +238,20 @@ if (!function_exists('injectRuntime')) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach ($attribute as $item) {
|
foreach ($attribute as $item) {
|
||||||
$item->execute($class, $method);
|
if ($item instanceof Route) {
|
||||||
|
$router[] = [$item, $class, $method];
|
||||||
|
} else {
|
||||||
|
$item->execute($class, $method);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!empty($router)) {
|
||||||
|
foreach ($router as $class) {
|
||||||
|
[$item, $class, $method] = $class;
|
||||||
|
$item->execute($class, $method);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -445,7 +456,7 @@ if (!function_exists('fire')) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param object $event
|
* @param object $event
|
||||||
*/
|
*/
|
||||||
function fire(object $event)
|
function fire(object $event)
|
||||||
{
|
{
|
||||||
di(EventDispatch::class)->dispatch($event);
|
di(EventDispatch::class)->dispatch($event);
|
||||||
@@ -540,7 +551,7 @@ if (!function_exists('trim_blank')) {
|
|||||||
if (!function_exists('get_file_extension')) {
|
if (!function_exists('get_file_extension')) {
|
||||||
|
|
||||||
function get_file_extension($filename): bool|int|string
|
function get_file_extension($filename): bool|int|string
|
||||||
{
|
{
|
||||||
$mime_types = [
|
$mime_types = [
|
||||||
'txt' => 'text/plain',
|
'txt' => 'text/plain',
|
||||||
'htm' => 'text/html',
|
'htm' => 'text/html',
|
||||||
@@ -877,11 +888,11 @@ if (!function_exists('env')) {
|
|||||||
if (!function_exists('di')) {
|
if (!function_exists('di')) {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $className
|
* @param string $className
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
function di(string $className): mixed
|
function di(string $className): mixed
|
||||||
{
|
{
|
||||||
return Kiri::getDi()->get($className);
|
return Kiri::getDi()->get($className);
|
||||||
@@ -892,11 +903,11 @@ if (!function_exists('di')) {
|
|||||||
if (!function_exists('duplicate')) {
|
if (!function_exists('duplicate')) {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $className
|
* @param string $className
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
function duplicate(string $className): mixed
|
function duplicate(string $className): mixed
|
||||||
{
|
{
|
||||||
$class = di($className);
|
$class = di($className);
|
||||||
|
|||||||
@@ -225,7 +225,6 @@ class Application extends BaseApplication
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws NotFindClassException
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ use Psr\Http\Server\MiddlewareInterface;
|
|||||||
* @param mixed $class
|
* @param mixed $class
|
||||||
* @param mixed|null $method
|
* @param mixed|null $method
|
||||||
* @return $this
|
* @return $this
|
||||||
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
public function execute(mixed $class, mixed $method = null): mixed
|
public function execute(mixed $class, mixed $method = null): mixed
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user