改名
This commit is contained in:
+23
-18
@@ -206,32 +206,37 @@ class Loader extends BaseObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $path
|
* @param string $path
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function loadByDirectory(string $path)
|
public function loadByDirectory(string $path)
|
||||||
{
|
{
|
||||||
foreach ($this->_fileMap as $fileName => $className) {
|
try {
|
||||||
if (!str_starts_with($fileName, $path)) {
|
foreach ($this->_fileMap as $fileName => $className) {
|
||||||
continue;
|
if (!str_starts_with($fileName, $path)) {
|
||||||
}
|
continue;
|
||||||
if (!isset($this->_classes[$className])) {
|
}
|
||||||
continue;
|
if (!isset($this->_classes[$className])) {
|
||||||
}
|
continue;
|
||||||
|
|
||||||
$annotations = $this->_classes[$className];
|
|
||||||
if (isset($annotations['target']) && !empty($annotations['target'])) {
|
|
||||||
foreach ($annotations['target'] as $value) {
|
|
||||||
$value->execute([$annotations['handler']]);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($annotations['methods'] as $name => $attribute) {
|
$annotations = $this->_classes[$className];
|
||||||
foreach ($attribute as $value) {
|
if (isset($annotations['target']) && !empty($annotations['target'])) {
|
||||||
if (!($value instanceof \Annotation\Attribute)) {
|
foreach ($annotations['target'] as $value) {
|
||||||
continue;
|
$value->execute([$annotations['handler']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($annotations['methods'] as $name => $attribute) {
|
||||||
|
foreach ($attribute as $value) {
|
||||||
|
if (!($value instanceof \Annotation\Attribute)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$value->execute([$annotations['handler'], $name]);
|
||||||
}
|
}
|
||||||
$value->execute([$annotations['handler'], $name]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Throwable $exception) {
|
||||||
|
$this->addError($exception, 'throwable');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,19 +35,6 @@ class DatabasesProviders extends Providers
|
|||||||
|
|
||||||
$event = Snowflake::app()->getEvent();
|
$event = Snowflake::app()->getEvent();
|
||||||
$event->on(Event::SERVER_WORKER_START, [$this, 'createPool']);
|
$event->on(Event::SERVER_WORKER_START, [$this, 'createPool']);
|
||||||
|
|
||||||
|
|
||||||
$event->on(Event::SERVER_WORKER_START, [$this, 'scanModel']);
|
|
||||||
$event->on(Event::SERVER_TASK_START, [$this, 'scanModel']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws ComponentException
|
|
||||||
*/
|
|
||||||
public function scanModel()
|
|
||||||
{
|
|
||||||
annotation()->instanceDirectoryFiles(MODEL_PATH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -527,7 +527,6 @@ class Router extends HttpService implements RouterInterface
|
|||||||
/**
|
/**
|
||||||
* @param $exception
|
* @param $exception
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws ComponentException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function exception($exception): mixed
|
private function exception($exception): mixed
|
||||||
|
|||||||
@@ -493,14 +493,11 @@ class Server extends HttpService
|
|||||||
{
|
{
|
||||||
$event = Snowflake::app()->getEvent();
|
$event = Snowflake::app()->getEvent();
|
||||||
$event->on(Event::SERVER_WORKER_START, function () {
|
$event->on(Event::SERVER_WORKER_START, function () {
|
||||||
try {
|
$system = Snowflake::app();
|
||||||
router()->loadRouterSetting();
|
|
||||||
|
|
||||||
$annotation = Snowflake::app()->getAttributes();
|
$system->getRouter()->loadRouterSetting();
|
||||||
$annotation->instanceDirectoryFiles(APP_PATH);
|
|
||||||
} catch (\Throwable $exception) {
|
$system->getAnnotation()->instanceDirectoryFiles(APP_PATH);
|
||||||
$this->addError($exception, 'throwable');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ use Snowflake\Channel;
|
|||||||
use Snowflake\Di\Service;
|
use Snowflake\Di\Service;
|
||||||
use Snowflake\Error\ErrorHandler;
|
use Snowflake\Error\ErrorHandler;
|
||||||
use Snowflake\Error\Logger;
|
use Snowflake\Error\Logger;
|
||||||
use Snowflake\Exception\ComponentException;
|
|
||||||
use Snowflake\Exception\InitException;
|
use Snowflake\Exception\InitException;
|
||||||
use Snowflake\Exception\NotFindClassException;
|
use Snowflake\Exception\NotFindClassException;
|
||||||
use Snowflake\Jwt\Jwt;
|
use Snowflake\Jwt\Jwt;
|
||||||
@@ -437,6 +436,16 @@ abstract class BaseApplication extends Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return SAnnotation
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function getAnnotation(): SAnnotation
|
||||||
|
{
|
||||||
|
return $this->get('annotation');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Async
|
* @return Async
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -482,7 +491,7 @@ abstract class BaseApplication extends Service
|
|||||||
'request' => ['class' => Request::class],
|
'request' => ['class' => Request::class],
|
||||||
'config' => ['class' => Config::class],
|
'config' => ['class' => Config::class],
|
||||||
'logger' => ['class' => Logger::class],
|
'logger' => ['class' => Logger::class],
|
||||||
'attributes' => ['class' => SAnnotation::class],
|
'annotation' => ['class' => SAnnotation::class],
|
||||||
'router' => ['class' => Router::class],
|
'router' => ['class' => Router::class],
|
||||||
'redis' => ['class' => Redis::class],
|
'redis' => ['class' => Redis::class],
|
||||||
'aop' => ['class' => Aop::class],
|
'aop' => ['class' => Aop::class],
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ use Rpc\Producer as RPCProducer;
|
|||||||
* @property Connection $connections
|
* @property Connection $connections
|
||||||
* @property Logger $logger
|
* @property Logger $logger
|
||||||
* @property Jwt $jwt
|
* @property Jwt $jwt
|
||||||
* @property SAnnotation $attributes
|
* @property SAnnotation $annotation
|
||||||
* @property Http2 $http2
|
* @property Http2 $http2
|
||||||
* @property BaseGoto $goto
|
* @property BaseGoto $goto
|
||||||
* @property Producer $kafka
|
* @property Producer $kafka
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class Snowflake
|
|||||||
*/
|
*/
|
||||||
public static function getAnnotation(): Annotation
|
public static function getAnnotation(): Annotation
|
||||||
{
|
{
|
||||||
return static::app()->getAttributes();
|
return static::app()->getAnnotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user