Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cf2f26ec21 | |||
| 2a52172af6 | |||
| 5bf8a7feb1 | |||
| 52d26c4481 | |||
| dd369d348c |
@@ -17,6 +17,7 @@ use Kiri\ToArray;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
|
use ReturnTypeWillChange;
|
||||||
use Traversable;
|
use Traversable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,7 +92,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
|||||||
*/
|
*/
|
||||||
public function addItem($item)
|
public function addItem($item)
|
||||||
{
|
{
|
||||||
array_push($this->_item, $item);
|
$this->_item[] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,7 +101,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
|||||||
*/
|
*/
|
||||||
public function getIterator(): Traversable|CollectionIterator|ArrayIterator
|
public function getIterator(): Traversable|CollectionIterator|ArrayIterator
|
||||||
{
|
{
|
||||||
return new CollectionIterator($this->model, $this->query, $this->_item);
|
return new CollectionIterator($this->model, $this->_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,7 +144,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
|||||||
* @param mixed $offset
|
* @param mixed $offset
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
*/
|
*/
|
||||||
public function offsetSet(mixed $offset, mixed $value)
|
#[ReturnTypeWillChange] public function offsetSet(mixed $offset, mixed $value)
|
||||||
{
|
{
|
||||||
$this->_item[$offset] = $value;
|
$this->_item[$offset] = $value;
|
||||||
}
|
}
|
||||||
@@ -152,7 +153,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
|||||||
/**
|
/**
|
||||||
* @param mixed $offset
|
* @param mixed $offset
|
||||||
*/
|
*/
|
||||||
public function offsetUnset(mixed $offset)
|
#[ReturnTypeWillChange] public function offsetUnset(mixed $offset)
|
||||||
{
|
{
|
||||||
if ($this->offsetExists($offset)) {
|
if ($this->offsetExists($offset)) {
|
||||||
unset($this->_item[$offset]);
|
unset($this->_item[$offset]);
|
||||||
|
|||||||
@@ -20,31 +20,17 @@ class CollectionIterator extends \ArrayIterator
|
|||||||
private ModelInterface|string $model;
|
private ModelInterface|string $model;
|
||||||
|
|
||||||
|
|
||||||
/** @var ActiveQuery */
|
|
||||||
private ActiveQuery $query;
|
|
||||||
|
|
||||||
|
|
||||||
private ?ModelInterface $_clone = null;
|
|
||||||
|
|
||||||
|
|
||||||
public function clean()
|
|
||||||
{
|
|
||||||
unset($this->query);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CollectionIterator constructor.
|
* CollectionIterator constructor.
|
||||||
* @param $model
|
* @param $model
|
||||||
* @param $query
|
|
||||||
* @param array $array
|
* @param array $array
|
||||||
* @param int $flags
|
* @param int $flags
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($model, $query, array $array = [], int $flags = 0)
|
public function __construct($model, array $array = [], int $flags = 0)
|
||||||
{
|
{
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
$this->query = $query;
|
|
||||||
parent::__construct($array, $flags);
|
parent::__construct($array, $flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -33,6 +33,7 @@ use Kiri\Exception\NotFindClassException;
|
|||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
use Kiri\ToArray;
|
use Kiri\ToArray;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
use ReturnTypeWillChange;
|
||||||
use validator\Validator;
|
use validator\Validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1000,7 +1001,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
|
|||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function offsetSet(mixed $offset, mixed $value)
|
#[ReturnTypeWillChange] public function offsetSet(mixed $offset, mixed $value)
|
||||||
{
|
{
|
||||||
$this->__set($offset, $value);
|
$this->__set($offset, $value);
|
||||||
}
|
}
|
||||||
@@ -1009,7 +1010,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
|
|||||||
* @param mixed $offset
|
* @param mixed $offset
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function offsetUnset(mixed $offset)
|
#[ReturnTypeWillChange] public function offsetUnset(mixed $offset)
|
||||||
{
|
{
|
||||||
if (!isset($this->_attributes[$offset])
|
if (!isset($this->_attributes[$offset])
|
||||||
&& !isset($this->_oldAttributes[$offset])) {
|
&& !isset($this->_oldAttributes[$offset])) {
|
||||||
|
|||||||
+5
-6
@@ -81,12 +81,11 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$eventProvider = Kiri::getDi()->get(EventProvider::class);
|
$this->eventProvider->on(OnWorkerStop::class, [$this, 'clear_connection'], 0);
|
||||||
$eventProvider->on(OnWorkerStop::class, [$this, 'clear_connection'], 0);
|
$this->eventProvider->on(OnWorkerExit::class, [$this, 'clear_connection'], 0);
|
||||||
$eventProvider->on(OnWorkerExit::class, [$this, 'clear_connection'], 0);
|
$this->eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0);
|
||||||
$eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0);
|
$this->eventProvider->on(Rollback::class, [$this, 'rollback'], 0);
|
||||||
$eventProvider->on(Rollback::class, [$this, 'rollback'], 0);
|
$this->eventProvider->on(Commit::class, [$this, 'commit'], 0);
|
||||||
$eventProvider->on(Commit::class, [$this, 'commit'], 0);
|
|
||||||
|
|
||||||
if (Db::transactionsActive()) {
|
if (Db::transactionsActive()) {
|
||||||
$this->beginTransaction();
|
$this->beginTransaction();
|
||||||
|
|||||||
Reference in New Issue
Block a user