This commit is contained in:
2021-03-29 16:27:12 +08:00
parent c1d37ce826
commit 4442397aa9
10 changed files with 25 additions and 16 deletions
+2 -1
View File
@@ -4,6 +4,7 @@
namespace Annotation; namespace Annotation;
use Database\InjectProperty;
use DirectoryIterator; use DirectoryIterator;
use Exception; use Exception;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
@@ -20,7 +21,7 @@ class Annotation extends Component
private Loader $_loader; private Loader $_loader;
public function init(): void #[Aspect(InjectProperty::class)] public function init(): void
{ {
$this->_loader = new Loader(); $this->_loader = new Loader();
} }
+3 -3
View File
@@ -136,10 +136,10 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
/** /**
* @throws Exception * @throws NotFindClassException
* @throws ReflectionException
*/ */
#[Aspect(InjectProperty::class)] #[Aspect(InjectProperty::class)] public function init()
public function init()
{ {
if (!Context::hasContext(Relation::class)) { if (!Context::hasContext(Relation::class)) {
$relation = Snowflake::createObject(Relation::class); $relation = Snowflake::createObject(Relation::class);
+2 -1
View File
@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Database; namespace Database;
use Annotation\Aspect;
use JetBrains\PhpStorm\Pure; use JetBrains\PhpStorm\Pure;
use ReflectionException; use ReflectionException;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
@@ -66,7 +67,7 @@ class Connection extends Component
/** /**
* @throws Exception * @throws Exception
*/ */
public function init() #[Aspect(InjectProperty::class)] public function init()
{ {
$event = Snowflake::app()->getEvent(); $event = Snowflake::app()->getEvent();
$event->on(Event::SYSTEM_RESOURCE_CLEAN, [$this, 'disconnect']); $event->on(Event::SYSTEM_RESOURCE_CLEAN, [$this, 'disconnect']);
+3 -1
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace HttpServer\Events; namespace HttpServer\Events;
use Annotation\Aspect;
use Database\InjectProperty;
use Exception; use Exception;
use HttpServer\Abstracts\Callback; use HttpServer\Abstracts\Callback;
use HttpServer\Exception\ExitException; use HttpServer\Exception\ExitException;
@@ -36,7 +38,7 @@ class OnRequest extends Callback
/** /**
* @throws Exception * @throws Exception
*/ */
public function init() #[Aspect(InjectProperty::class)] public function init()
{ {
$this->event = Snowflake::app()->getEvent(); $this->event = Snowflake::app()->getEvent();
$this->logger = Snowflake::app()->getLogger(); $this->logger = Snowflake::app()->getLogger();
+3 -1
View File
@@ -3,7 +3,9 @@ declare(strict_types=1);
namespace HttpServer\Route; namespace HttpServer\Route;
use Annotation\Aspect;
use Closure; use Closure;
use Database\InjectProperty;
use Exception; use Exception;
use HttpServer\Abstracts\HttpService; use HttpServer\Abstracts\HttpService;
use HttpServer\Http\Request; use HttpServer\Http\Request;
@@ -57,7 +59,7 @@ class Router extends HttpService implements RouterInterface
* @throws ConfigException * @throws ConfigException
* 初始化函数路径 * 初始化函数路径
*/ */
public function init() #[Aspect(InjectProperty::class)] public function init()
{ {
$this->dir = Config::get('http.namespace', false, $this->dir); $this->dir = Config::get('http.namespace', false, $this->dir);
} }
+3 -1
View File
@@ -4,6 +4,8 @@
namespace HttpServer; namespace HttpServer;
use Annotation\Aspect;
use Database\InjectProperty;
use Exception; use Exception;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
use Snowflake\Abstracts\Config; use Snowflake\Abstracts\Config;
@@ -30,7 +32,7 @@ class Shutdown extends Component
/** /**
* @throws Exception * @throws Exception
*/ */
public function init() #[Aspect(InjectProperty::class)] public function init()
{ {
$this->taskDirectory = storage(null, 'pid/task'); $this->taskDirectory = storage(null, 'pid/task');
$this->workerDirectory = storage(null, 'pid/worker'); $this->workerDirectory = storage(null, 'pid/worker');
-5
View File
@@ -12,11 +12,6 @@ namespace Snowflake\Abstracts;
use Exception; use Exception;
use JetBrains\PhpStorm\Pure; use JetBrains\PhpStorm\Pure;
use ReflectionException;
use Snowflake\Aop;
use Snowflake\Error\Logger;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Swoole\Coroutine; use Swoole\Coroutine;
+3 -1
View File
@@ -10,9 +10,11 @@ declare(strict_types=1);
namespace Snowflake; namespace Snowflake;
use Annotation\Aspect;
use Console\Console; use Console\Console;
use Console\ConsoleProviders; use Console\ConsoleProviders;
use Database\DatabasesProviders; use Database\DatabasesProviders;
use Database\InjectProperty;
use Exception; use Exception;
use HttpServer\ServerProviders; use HttpServer\ServerProviders;
use Snowflake\Abstracts\BaseApplication; use Snowflake\Abstracts\BaseApplication;
@@ -46,7 +48,7 @@ class Application extends BaseApplication
/** /**
* @throws NotFindClassException * @throws NotFindClassException
*/ */
public function init() #[Aspect(InjectProperty::class)] public function init()
{ {
$this->import(ConsoleProviders::class); $this->import(ConsoleProviders::class);
$this->import(DatabasesProviders::class); $this->import(DatabasesProviders::class);
+3 -1
View File
@@ -9,6 +9,8 @@ declare(strict_types=1);
namespace Snowflake\Cache; namespace Snowflake\Cache;
use Annotation\Aspect;
use Database\InjectProperty;
use Exception; use Exception;
use ReflectionException; use ReflectionException;
use Snowflake\Abstracts\Component; use Snowflake\Abstracts\Component;
@@ -36,7 +38,7 @@ class Redis extends Component
/** /**
* @throws Exception * @throws Exception
*/ */
public function init() #[Aspect(InjectProperty::class)] public function init()
{ {
$event = Snowflake::app()->getEvent(); $event = Snowflake::app()->getEvent();
$event->on(Event::SYSTEM_RESOURCE_CLEAN, [$this, 'destroy']); $event->on(Event::SYSTEM_RESOURCE_CLEAN, [$this, 'destroy']);
+3 -1
View File
@@ -3,6 +3,8 @@ declare(strict_types=1);
namespace Snowflake\Jwt; namespace Snowflake\Jwt;
use Annotation\Aspect;
use Database\InjectProperty;
use Exception; use Exception;
use HttpServer\Http\HttpHeaders; use HttpServer\Http\HttpHeaders;
use ReflectionException; use ReflectionException;
@@ -79,7 +81,7 @@ mlAZUEjsoaT9vjvjGTxl3uCm0TX5KTgtSJIt2kA1tYVjQef+/iZTHxY=
/** /**
* @throws ConfigException * @throws ConfigException
*/ */
public function init() #[Aspect(InjectProperty::class)] public function init()
{ {
if (!Config::has('ssl.public') || !Config::has('ssl.private')) { if (!Config::has('ssl.public') || !Config::has('ssl.private')) {
return; return;