This commit is contained in:
as2252258@163.com
2021-04-24 19:46:24 +08:00
parent 7b8c0dbf63
commit 1867083b14
3 changed files with 385 additions and 376 deletions
+26 -11
View File
@@ -31,7 +31,7 @@ class Annotation extends Component
*/
public function addSets(string $class, string $setName, string $method)
{
$this->_model_sets[$class . '::' . $setName] = $method;
$this->_model_sets[$class][$setName] = $method;
}
/**
@@ -41,7 +41,7 @@ class Annotation extends Component
*/
public function addGets(string $class, string $setName, string $method)
{
$this->_model_gets[$class . '::' . $setName] = $method;
$this->_model_gets[$class][$setName] = $method;
}
@@ -52,7 +52,7 @@ class Annotation extends Component
*/
public function addRelate(string $class, string $setName, string $method)
{
$this->_model_relate[$class . '::' . $setName] = $method;
$this->_model_relate[$class][$setName] = $method;
}
@@ -63,16 +63,25 @@ class Annotation extends Component
*/
public function getGetMethodName(string $class, string $setName): ?string
{
if (isset($this->_model_gets[$class . '::' . $setName])) {
return $this->_model_gets[$class . '::' . $setName];
$gets = $this->_model_gets[$class] ?? $this->_model_relate[$class] ?? null;
if ($gets == null) {
return null;
}
if (isset($this->_model_relate[$class . '::' . $setName])) {
return $this->_model_relate[$class . '::' . $setName];
}
return null;
return $gets[$setName] ?? null;
}
/**
* @param string $class
* @return array
*/
public function getModelMethods(string $class): array
{
return $this->_model_gets[$class] ?? [];
}
/**
* @param string $class
* @param string $setName
@@ -80,8 +89,14 @@ class Annotation extends Component
*/
public function getSetMethodName(string $class, string $setName): ?string
{
if (isset($this->_model_sets[$class . '::' . $setName])) {
return $this->_model_relate[$class . '::' . $setName];
if (!isset($this->_model_sets[$class])) {
return null;
}
$lists = $this->_model_sets[$class];
if (isset($lists[$setName])) {
return $lists[$setName];
}
return null;
}