This commit is contained in:
2021-02-23 17:30:10 +08:00
parent 31d5024663
commit 5e2cf4db18
6 changed files with 33 additions and 4 deletions
+7
View File
@@ -39,6 +39,13 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
protected ActiveQuery $query; protected ActiveQuery $query;
public function clean()
{
unset($this->query, $this->model, $this->_item);
}
/** /**
* Collection constructor. * Collection constructor.
* *
+6
View File
@@ -27,6 +27,12 @@ class CollectionIterator extends \ArrayIterator
private ActiveQuery $query; private ActiveQuery $query;
public function clean()
{
unset($this->query);
}
/** /**
* CollectionIterator constructor. * CollectionIterator constructor.
* @param $model * @param $model
+10
View File
@@ -51,6 +51,16 @@ class Pagination extends Component
} }
public function clean()
{
unset($this->activeQuery, $this->_callback, $this->_group);
$this->_offset = 0;
$this->_limit = 100;
$this->_max = 0;
$this->_length = 0;;
}
/** /**
* @param array|Closure $callback * @param array|Closure $callback
* @throws Exception * @throws Exception
+1
View File
@@ -44,6 +44,7 @@ class Relation extends Component
* @param string $identification * @param string $identification
* @param $localValue * @param $localValue
* @return mixed * @return mixed
* @throws Exception
*/ */
public function first(string $identification, $localValue): mixed public function first(string $identification, $localValue): mixed
{ {
+5 -3
View File
@@ -9,7 +9,9 @@ use Closure;
use HttpServer\Controller; use HttpServer\Controller;
use HttpServer\Http\Context; use HttpServer\Http\Context;
use HttpServer\Http\Request; use HttpServer\Http\Request;
use ReflectionException;
use Snowflake\Exception\ComponentException; use Snowflake\Exception\ComponentException;
use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
/** /**
@@ -54,12 +56,12 @@ class Dispatch
/** /**
* 设置作用域 * @throws ReflectionException
* @throws ComponentException * @throws NotFindClassException
*/ */
protected function bind() protected function bind()
{ {
$class = $this->bindRequest(objectPool(Controller::class)); $class = $this->bindRequest(Snowflake::createObject(Controller::class));
$this->handler = Closure::bind($this->handler, $class); $this->handler = Closure::bind($this->handler, $class);
} }
+4 -1
View File
@@ -6,6 +6,7 @@ namespace Snowflake\Pool;
use Exception; use Exception;
use ReflectionException; use ReflectionException;
use Snowflake\Event;
use Snowflake\Exception\NotFindClassException; use Snowflake\Exception\NotFindClassException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
@@ -37,7 +38,9 @@ class ObjectPool extends \Snowflake\Abstracts\Pool
if (is_object($config)) { if (is_object($config)) {
return $config; return $config;
} }
return $this->getFromChannel(md5($config), [$config, $construct]); $object = $this->getFromChannel(md5($config), [$config, $construct]);
listen(Event::EVENT_AFTER_REQUEST, [$object, 'clean']);
return $object;
} }