From 7eb615111122a40a59bf39a6652e39686a7c382d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 8 Dec 2021 11:32:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Connection.php | 18 ++++++------------ src/DatabasesProviders.php | 8 -------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index 4f7f00f..d1bbd72 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -75,24 +75,18 @@ class Connection extends Component public Schema $_schema; - /** - * @var EventProvider - */ - #[Inject(EventProvider::class)] - public EventProvider $eventProvider; - - /** * execute by __construct * @throws Exception */ public function init() { - $this->eventProvider->on(OnWorkerStop::class, [$this, 'clear_connection'], 0); - $this->eventProvider->on(OnWorkerExit::class, [$this, 'clear_connection'], 0); - $this->eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0); - $this->eventProvider->on(Rollback::class, [$this, 'rollback'], 0); - $this->eventProvider->on(Commit::class, [$this, 'commit'], 0); + $eventProvider = Kiri::getDi()->get(EventProvider::class); + $eventProvider->on(OnWorkerStop::class, [$this, 'clear_connection'], 0); + $eventProvider->on(OnWorkerExit::class, [$this, 'clear_connection'], 0); + $eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0); + $eventProvider->on(Rollback::class, [$this, 'rollback'], 0); + $eventProvider->on(Commit::class, [$this, 'commit'], 0); if (Db::transactionsActive()) { $this->beginTransaction(); diff --git a/src/DatabasesProviders.php b/src/DatabasesProviders.php index e515a0e..6f01445 100644 --- a/src/DatabasesProviders.php +++ b/src/DatabasesProviders.php @@ -11,7 +11,6 @@ use Kiri\Application; use Kiri\Events\EventProvider; use Kiri\Exception\ConfigException; use Kiri\Kiri; -use Note\Inject; use Server\Events\OnWorkerStart; /** @@ -24,13 +23,6 @@ class DatabasesProviders extends Providers private array $_pooLength = ['min' => 0, 'max' => 1]; - /** - * @var EventProvider - */ - #[Inject(EventProvider::class)] - public EventProvider $eventProvider; - - /** * @param Application $application * @throws Exception