This commit is contained in:
2021-08-23 19:10:44 +08:00
parent 0744a4fac8
commit ebb23807cf
3 changed files with 41 additions and 19 deletions
+19 -1
View File
@@ -5,8 +5,8 @@ namespace Kiri;
use Exception;
use ReflectionException;
use Kiri\Abstracts\Component;
use ReflectionException;
defined('ASPECT_ERROR') or define('ASPECT_ERROR', 'Aspect annotation must implement ');
@@ -40,6 +40,24 @@ class AspectManager extends Component
}
/**
* @param string $class
* @param string $method
* @param string $aspect
*/
public function addAspect(string $class, string $method, string $aspect)
{
$alias = $class . '::' . $method;
if (!isset(static::$_aop[$alias])) {
static::$_aop[$alias] = [];
}
if (in_array($aspect, static::$_aop[$alias])) {
return;
}
static::$_aop[$alias][] = $aspect;
}
/**
* @param $handler
* @return bool