改名
This commit is contained in:
+24
-12
@@ -314,25 +314,37 @@ class ActiveRecord extends BaseActiveRecord
|
|||||||
$attributes = Snowflake::app()->getAttributes();
|
$attributes = Snowflake::app()->getAttributes();
|
||||||
$callback = $attributes->getByClass(static::class);
|
$callback = $attributes->getByClass(static::class);
|
||||||
|
|
||||||
var_dump($callback);
|
|
||||||
|
|
||||||
$data = $this->_attributes;
|
$data = $this->_attributes;
|
||||||
foreach ($callback as $key => $item) {
|
foreach ($callback as $key => $item) {
|
||||||
foreach ($item['attributes'] as $attribute) {
|
$data = $this->resolveAttributes($item, $data);
|
||||||
if (!($attribute instanceof Get)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$name = $attribute->name;
|
|
||||||
|
|
||||||
$result = call_user_func($item['handler'], $data[$name]);
|
|
||||||
|
|
||||||
$data[$name] = $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_merge($data, $this->runRelate());
|
return array_merge($data, $this->runRelate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $item
|
||||||
|
* @param $data
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function resolveAttributes($item, $data): array
|
||||||
|
{
|
||||||
|
if (!isset($item['attributes'])) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
foreach ($item['attributes'] as $attribute) {
|
||||||
|
if (!($attribute instanceof Get)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$name = $attribute->name;
|
||||||
|
$result = call_user_func($item['handler'], $data[$name]);
|
||||||
|
$data[$name] = $result;
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|||||||
Reference in New Issue
Block a user