modify
This commit is contained in:
@@ -310,24 +310,9 @@ class ActiveRecord extends BaseActiveRecord
|
|||||||
$data[$key] = $this->runAnnotation($key, $data[$key] ?? null);
|
$data[$key] = $this->runAnnotation($key, $data[$key] ?? null);
|
||||||
}
|
}
|
||||||
$data = array_merge($data, $this->runRelate());
|
$data = array_merge($data, $this->runRelate());
|
||||||
$this->recover();
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function recover()
|
|
||||||
{
|
|
||||||
$this->clean();
|
|
||||||
|
|
||||||
/** @var Channel $channel */
|
|
||||||
$channel = Snowflake::app()->get('channel');
|
|
||||||
$channel->push($this, get_called_class());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|||||||
@@ -120,12 +120,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
|||||||
if (is_object($model)) {
|
if (is_object($model)) {
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Channel $channel */
|
|
||||||
$channel = Snowflake::app()->get('channel');
|
|
||||||
return $channel->pop($model, function () use ($model) {
|
|
||||||
return new $model();
|
return new $model();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1029,13 +1029,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
*/
|
*/
|
||||||
public static function populate(array $data): static
|
public static function populate(array $data): static
|
||||||
{
|
{
|
||||||
$className = get_called_class();
|
$model = new static();
|
||||||
|
|
||||||
/** @var Channel $channel */
|
|
||||||
$channel = Snowflake::app()->get('channel');
|
|
||||||
$model = $channel->pop($className, function () use ($className) {
|
|
||||||
return new $className();
|
|
||||||
});
|
|
||||||
$model->_attributes = $data;
|
$model->_attributes = $data;
|
||||||
$model->setIsCreate(false);
|
$model->setIsCreate(false);
|
||||||
$model->refresh();
|
$model->refresh();
|
||||||
|
|||||||
@@ -62,12 +62,7 @@ class CollectionIterator extends \ArrayIterator
|
|||||||
if (is_object($model)) {
|
if (is_object($model)) {
|
||||||
$model = get_class($model);
|
$model = get_class($model);
|
||||||
}
|
}
|
||||||
|
$model = new $model();
|
||||||
/** @var Channel $channel */
|
|
||||||
$channel = Snowflake::app()->get('channel');
|
|
||||||
$model = $channel->pop($model, function () use ($model) {
|
|
||||||
return new $model();
|
|
||||||
});
|
|
||||||
return $model->setAttributes($current);
|
return $model->setAttributes($current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
namespace Database;
|
|
||||||
|
|
||||||
|
|
||||||
use JetBrains\PhpStorm\Pure;
|
|
||||||
use Snowflake\IAspect;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class InjectProperty
|
|
||||||
* @package Database
|
|
||||||
*/
|
|
||||||
class InjectProperty implements IAspect
|
|
||||||
{
|
|
||||||
|
|
||||||
private string $className = '';
|
|
||||||
private string $methodName = '';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* InjectProperty constructor.
|
|
||||||
* @param array $handler
|
|
||||||
*/
|
|
||||||
public function __construct(public array $handler)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function invoke(): mixed
|
|
||||||
{
|
|
||||||
$data = call_user_func($this->handler, func_get_args());
|
|
||||||
|
|
||||||
$this->handler[0]->createAnnotation();
|
|
||||||
|
|
||||||
echo 'inject property.' . PHP_EOL;
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user