改名
This commit is contained in:
+26
-11
@@ -168,24 +168,39 @@ class Annotation extends Component
|
|||||||
$annotation = $annotation->execute([$object, $value->getName()]);
|
$annotation = $annotation->execute([$object, $value->getName()]);
|
||||||
$this->_prepertyes[get_class($object)][$value->getName()] = $annotation;
|
$this->_prepertyes[get_class($object)][$value->getName()] = $annotation;
|
||||||
|
|
||||||
if (str_contains(env('workerId'), 'Task')) {
|
|
||||||
var_dump(get_class($object) . '::' . $value->getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($value->isPublic()) {
|
if ($value->isPublic()) {
|
||||||
$object->{$value->getName()} = $annotation;
|
continue;
|
||||||
} else {
|
}
|
||||||
$name = 'set' . ucfirst($value->getName());
|
if (!method_exists($object, ($name = 'set' . ucfirst($value->getName())))) {
|
||||||
if (!method_exists($object, $name)) {
|
throw new NotFindPropertyException('set property need method ' . $name);
|
||||||
throw new NotFindPropertyException('set property need method ' . $name);
|
|
||||||
}
|
|
||||||
$object->$name($annotation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $class
|
||||||
|
* @param string $property
|
||||||
|
* @return mixed|null
|
||||||
|
*/
|
||||||
|
public function getPropertyAnnotation($class, $property = ''): ?array
|
||||||
|
{
|
||||||
|
if (is_object($class)) {
|
||||||
|
$class = get_class($class);
|
||||||
|
}
|
||||||
|
if (!isset($this->_prepertyes[$class])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($property)) {
|
||||||
|
return $this->_prepertyes[$class][$property] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_prepertyes[$class];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $class
|
* @param string $class
|
||||||
* @return ReflectionClass|null
|
* @return ReflectionClass|null
|
||||||
|
|||||||
@@ -108,7 +108,23 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
} else {
|
} else {
|
||||||
$this->_relation = Context::getContext(Relation::class);
|
$this->_relation = Context::getContext(Relation::class);
|
||||||
}
|
}
|
||||||
$this->_annotations = annotation()->getMethods(get_called_class());
|
$this->createAnnotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ComponentException
|
||||||
|
*/
|
||||||
|
private function createAnnotation()
|
||||||
|
{
|
||||||
|
$annotation = Snowflake::app()->getAttributes();
|
||||||
|
|
||||||
|
$this->_annotations = $annotation->getMethods(get_called_class());
|
||||||
|
|
||||||
|
$lists = $annotation->getPropertyAnnotation(get_called_class());
|
||||||
|
foreach ($lists as $name => $list) {
|
||||||
|
$this->{$name} = $list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user