Files
kiri-core/Annotation/Aspect.php
T

50 lines
951 B
PHP
Raw Normal View History

2021-03-29 02:34:31 +08:00
<?php
namespace Annotation;
2021-03-29 10:05:51 +08:00
use Exception;
2021-03-29 03:09:55 +08:00
use Snowflake\Aop;
use Snowflake\IAspect;
use Snowflake\Snowflake;
defined('ASPECT_ERROR') or define('ASPECT_ERROR', 'Aspect annotation must implement ');
2021-03-29 02:34:31 +08:00
/**
* Class Aspect
* @package Annotation
*/
2021-03-29 03:09:55 +08:00
#[\Attribute(\Attribute::TARGET_METHOD)] class Aspect extends Attribute
2021-03-29 02:34:31 +08:00
{
/**
* Aspect constructor.
2021-03-29 03:09:55 +08:00
* @param string $aspect
2021-03-29 02:34:31 +08:00
*/
2021-03-29 03:09:55 +08:00
public function __construct(public string $aspect)
2021-03-29 02:34:31 +08:00
{
}
2021-07-12 17:17:36 +08:00
/**
* @throws Exception
*/
public function execute(mixed $class, mixed $method = ''): bool
2021-03-29 02:34:31 +08:00
{
2021-05-03 03:48:52 +08:00
// TODO: Change the autogenerated stub
2021-08-02 19:06:44 +08:00
// if (!in_array(IAspect::class, class_implements($this->aspect))) {
// throw new Exception(ASPECT_ERROR . IAspect::class);
// }
// /** @var Aop $aop */
// $aop = Snowflake::getDi()->get(Aop::class);
//
// $aop->aop_add([$class, $method], $this->aspect);
2021-03-29 03:09:55 +08:00
2021-05-03 03:48:52 +08:00
return true;
2021-03-29 02:34:31 +08:00
}
}