From 2bb36e378f8c43e9b539481961e16f9dff1332eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 23 Feb 2021 19:00:22 +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 --- System/Pool/ObjectPool.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/System/Pool/ObjectPool.php b/System/Pool/ObjectPool.php index 5e5dd6a7..a26d86b1 100644 --- a/System/Pool/ObjectPool.php +++ b/System/Pool/ObjectPool.php @@ -7,6 +7,7 @@ namespace Snowflake\Pool; use Exception; use ReflectionException; use Snowflake\Event; +use Snowflake\Exception\ComponentException; use Snowflake\Exception\NotFindClassException; use Snowflake\Snowflake; @@ -38,11 +39,7 @@ class ObjectPool extends \Snowflake\Abstracts\Pool if (is_object($config)) { return $config; } - $object = $this->getFromChannel($name = md5($config), [$config, $construct]); - if (method_exists($object, 'clean')) { - $object->clean(); - } - return $object; + return $this->getFromChannel($name = md5($config), [$config, $construct]); } @@ -62,9 +59,13 @@ class ObjectPool extends \Snowflake\Abstracts\Pool /** * @param string $name * @param $object + * @throws ComponentException */ public function release(string $name, mixed $object) { + if (method_exists($object, 'clean')) { + listen(Event::EVENT_AFTER_REQUEST,[$object,'clean']); + } $this->push($name, $object); }