mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-08 09:15:37 +08:00
add plugin loader support
This commit is contained in:
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Annotation;
|
||||
|
||||
use ZM\Annotation\Interfaces\Level;
|
||||
|
||||
/**
|
||||
* 注解全局存取位置
|
||||
*/
|
||||
@@ -36,4 +38,20 @@ class AnnotationMap
|
||||
self::$_list = array_merge(self::$_list, $parser->generateAnnotationList());
|
||||
self::$_map = $parser->getAnnotationMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序所有的注解
|
||||
*/
|
||||
public static function sortAnnotationList(): void
|
||||
{
|
||||
foreach (self::$_list as $class => $annotations) {
|
||||
if (is_a($class, Level::class, true)) {
|
||||
usort(self::$_list[$class], function ($a, $b) {
|
||||
$left = $a->getLevel(); /** @phpstan-ignore-line */
|
||||
$right = $b->getLevel(); /* @phpstan-ignore-line */
|
||||
return $left > $right ? -1 : ($left == $right ? 0 : 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user