111
This commit is contained in:
+4
-129
@@ -19,122 +19,9 @@ class Annotation extends Component
|
||||
|
||||
private Loader $_loader;
|
||||
|
||||
private array $_model_sets = [];
|
||||
private array $_model_gets = [];
|
||||
private array $_model_relate = [];
|
||||
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $setName
|
||||
* @param string $method
|
||||
*/
|
||||
public function addSets(string $class, string $setName, string $method)
|
||||
{
|
||||
$this->_model_sets[$class][$setName] = $method;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $setName
|
||||
* @param string $method
|
||||
*/
|
||||
public function addGets(string $class, string $setName, string $method)
|
||||
{
|
||||
$this->_model_gets[$class][$setName] = $method;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $setName
|
||||
* @param string $method
|
||||
*/
|
||||
public function addRelate(string $class, string $setName, string $method)
|
||||
{
|
||||
$this->_model_relate[$class][$setName] = $method;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $class
|
||||
* @return array
|
||||
*/
|
||||
public function getGets($class): array
|
||||
{
|
||||
return $this->_model_gets[$class] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $class
|
||||
* @return array
|
||||
*/
|
||||
public function getSets($class): array
|
||||
{
|
||||
return $this->_model_gets[$class] ?? [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string|null $setName
|
||||
* @return array|string|null
|
||||
*/
|
||||
public function getGetMethodName(string $class, string $setName = null): array|null|string
|
||||
{
|
||||
$gets = $this->_model_gets[$class] ?? null;
|
||||
if ($gets == null) {
|
||||
return null;
|
||||
}
|
||||
if (empty($setName)) return $gets;
|
||||
return $gets[$setName] ?? null;
|
||||
}
|
||||
|
||||
|
||||
public function runGet($name, $value)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string|null $method
|
||||
* @return array|string|null
|
||||
*/
|
||||
public function getRelateMethods(string $class, string $method = null): array|null|string
|
||||
{
|
||||
$gets = $this->_model_relate[$class] ?? null;
|
||||
if ($gets == null) {
|
||||
return null;
|
||||
}
|
||||
if (empty($method)) return $gets;
|
||||
return $gets[$method] ?? null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $setName
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getSetMethodName(string $class, string $setName): ?string
|
||||
{
|
||||
if (!isset($this->_model_sets[$class])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$lists = $this->_model_sets[$class];
|
||||
|
||||
if (isset($lists[$setName])) {
|
||||
return $lists[$setName];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function init(): void
|
||||
{
|
||||
$this->_loader = new Loader();
|
||||
@@ -159,19 +46,7 @@ class Annotation extends Component
|
||||
return $this->_loader = $loader;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $method
|
||||
* @return array 根据类名获取注解
|
||||
* 根据类名获取注解
|
||||
*/
|
||||
public function getMethods(string $className, string $method = ''): mixed
|
||||
{
|
||||
return $this->_loader->getMethod($className, $method);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @throws ReflectionException
|
||||
|
||||
Reference in New Issue
Block a user