This commit is contained in:
2021-04-02 18:40:50 +08:00
parent 98986ffe9d
commit bdd9f4008f
7 changed files with 40 additions and 43 deletions
+23 -18
View File
@@ -206,32 +206,37 @@ class Loader extends BaseObject
/**
* @param string $path
* @throws Exception
*/
public function loadByDirectory(string $path)
{
foreach ($this->_fileMap as $fileName => $className) {
if (!str_starts_with($fileName, $path)) {
continue;
}
if (!isset($this->_classes[$className])) {
continue;
}
$annotations = $this->_classes[$className];
if (isset($annotations['target']) && !empty($annotations['target'])) {
foreach ($annotations['target'] as $value) {
$value->execute([$annotations['handler']]);
try {
foreach ($this->_fileMap as $fileName => $className) {
if (!str_starts_with($fileName, $path)) {
continue;
}
if (!isset($this->_classes[$className])) {
continue;
}
}
foreach ($annotations['methods'] as $name => $attribute) {
foreach ($attribute as $value) {
if (!($value instanceof \Annotation\Attribute)) {
continue;
$annotations = $this->_classes[$className];
if (isset($annotations['target']) && !empty($annotations['target'])) {
foreach ($annotations['target'] as $value) {
$value->execute([$annotations['handler']]);
}
}
foreach ($annotations['methods'] as $name => $attribute) {
foreach ($attribute as $value) {
if (!($value instanceof \Annotation\Attribute)) {
continue;
}
$value->execute([$annotations['handler'], $name]);
}
$value->execute([$annotations['handler'], $name]);
}
}
} catch (Throwable $exception) {
$this->addError($exception, 'throwable');
}
}