modify plugin name
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Kiri\Annotation;
|
||||
|
||||
|
||||
/**
|
||||
* Class Attribute
|
||||
* @package Annotation
|
||||
*/
|
||||
abstract class Attribute implements IAnnotation
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param static $class
|
||||
* @param mixed|string $method
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function execute(mixed $class, mixed $method = ''): mixed
|
||||
{
|
||||
// TODO: Implement execute() method.
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
|
||||
|
||||
namespace Kiri\Annotation;
|
||||
|
||||
|
||||
/**
|
||||
* Class Attribute
|
||||
* @package Annotation
|
||||
*/
|
||||
abstract class AbstractAttribute implements IAnnotation
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param static $class
|
||||
* @param mixed|string $method
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function execute(mixed $class, mixed $method = ''): mixed
|
||||
{
|
||||
// TODO: Implement execute() method.
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ defined('ASPECT_ERROR') or define('ASPECT_ERROR', 'Aspect annotation must implem
|
||||
* Class Aspect
|
||||
* @package Annotation
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Aspect extends Attribute
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Aspect extends AbstractAttribute
|
||||
{
|
||||
|
||||
|
||||
|
||||
+48
-25
@@ -5,42 +5,65 @@ namespace Kiri\Annotation;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Kiri\Events\EventProvider;
|
||||
use Kiri;
|
||||
use Kiri\Events\EventProvider;
|
||||
|
||||
|
||||
/**
|
||||
* Class Event
|
||||
* @package Annotation
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Event extends Attribute
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Event extends AbstractAttribute
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Event constructor.
|
||||
* @param string $name
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct(public string $name, public array $params = [])
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Event constructor.
|
||||
* @param string $name
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct(public string $name, public array $params = [])
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $class
|
||||
* @param mixed|null $method
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute(mixed $class, mixed $method = null): bool
|
||||
{
|
||||
$pro = Kiri::getDi()->get(EventProvider::class);
|
||||
if (is_string($class)) {
|
||||
$class = Kiri::getDi()->get($class);
|
||||
}
|
||||
$pro->on($this->name, [$class, $method]);
|
||||
return true;
|
||||
}
|
||||
public function __serialize()
|
||||
{
|
||||
// TODO: Implement __serialize() method.
|
||||
}
|
||||
|
||||
|
||||
public function __unserialize(array $data)
|
||||
{
|
||||
// TODO: Implement __unserialize() method.
|
||||
}
|
||||
|
||||
|
||||
public function serialize(): array
|
||||
{
|
||||
// TODO: Implement __serialize() method.
|
||||
}
|
||||
|
||||
|
||||
public function unserialize(array|string $data): void
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param mixed $class
|
||||
* @param mixed|null $method
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute(mixed $class, mixed $method = null): bool
|
||||
{
|
||||
$pro = Kiri::getDi()->get(EventProvider::class);
|
||||
if (is_string($class)) {
|
||||
$class = Kiri::getDi()->get($class);
|
||||
}
|
||||
$pro->on($this->name, [$class, $method]);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use ReflectionProperty;
|
||||
* Class Inject
|
||||
* @package Annotation
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)] class Inject extends Attribute
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)] class Inject extends AbstractAttribute
|
||||
{
|
||||
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ class Loader extends Component
|
||||
}
|
||||
$this->appendFileToDirectory($path->getRealPath(), $replace->getName());
|
||||
} catch (Throwable $throwable) {
|
||||
$this->error(jTraceEx($throwable), 'throwable');
|
||||
$this->logger->error(jTraceEx($throwable));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ class Loader extends Component
|
||||
}
|
||||
return $paths;
|
||||
} catch (Throwable $exception) {
|
||||
$this->addError($exception, 'throwable');
|
||||
$this->logger->addError($exception, 'throwable');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Kiri\Annotation;
|
||||
|
||||
use Kiri;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_CLASS)] class Mapping extends Attribute
|
||||
#[\Attribute(\Attribute::TARGET_CLASS)] class Mapping extends AbstractAttribute
|
||||
{
|
||||
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
namespace Kiri\Annotation\Route;
|
||||
|
||||
|
||||
use Kiri\Annotation\Attribute;
|
||||
use Kiri\Annotation\AbstractAttribute;
|
||||
|
||||
/**
|
||||
* Class Document
|
||||
* @package Annotation\Route
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Document extends Attribute
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Document extends AbstractAttribute
|
||||
{
|
||||
|
||||
const INTEGER = 'int';
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Annotation\Route;
|
||||
|
||||
enum Method
|
||||
{
|
||||
|
||||
|
||||
case REQUEST_POST;
|
||||
case REQUEST_GET;
|
||||
case REQUEST_HEAD;
|
||||
case REQUEST_OPTIONS;
|
||||
case REQUEST_DELETE;
|
||||
case REQUEST_PUT;
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
namespace Kiri\Annotation\Route;
|
||||
|
||||
|
||||
use Kiri\Annotation\Attribute;
|
||||
use Kiri\Annotation\AbstractAttribute;
|
||||
use Kiri\Message\Handler\Abstracts\MiddlewareManager;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
|
||||
@@ -12,7 +12,7 @@ use Psr\Http\Server\MiddlewareInterface;
|
||||
* Class Middleware
|
||||
* @package Annotation\Route
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Middleware extends Attribute
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Middleware extends AbstractAttribute
|
||||
{
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Annotation\Route;
|
||||
|
||||
use Kiri\Annotation\AbstractAttribute;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class RequestMapping extends AbstractAttribute
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param Method $method
|
||||
* @param string $path
|
||||
* @param string|null $version
|
||||
*/
|
||||
public function __construct(Method $method, string $path, string $version = null)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,11 +4,11 @@
|
||||
namespace Kiri\Annotation\Route;
|
||||
|
||||
|
||||
use Kiri\Annotation\Attribute;
|
||||
use Kiri\Annotation\AbstractAttribute;
|
||||
use Kiri\Message\Handler\Router;
|
||||
use Kiri;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Route extends Attribute
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Route extends AbstractAttribute
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
namespace Kiri\Annotation\Route;
|
||||
|
||||
|
||||
use Kiri\Annotation\Attribute;
|
||||
use Kiri\Annotation\AbstractAttribute;
|
||||
|
||||
/**
|
||||
* Class Socket
|
||||
* @package Annotation
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Socket extends Attribute
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Socket extends AbstractAttribute
|
||||
{
|
||||
|
||||
const CLOSE = 'CLOSE';
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Annotation\Route;
|
||||
|
||||
use Kiri\Annotation\Aspect;
|
||||
use Kiri\Error\LoggerAspect;
|
||||
|
||||
class TestController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
#[RequestMapping(method: Method::REQUEST_GET, path: '/', version: 'v1')]
|
||||
#[Aspect(aspect: LoggerAspect::class)]
|
||||
#[Middleware(middleware: LoggerAspect::class)]
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace Kiri\Annotation;
|
||||
* Class Target
|
||||
* @package Annotation
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_CLASS)] class Target extends Attribute
|
||||
#[\Attribute(\Attribute::TARGET_CLASS)] class Target extends AbstractAttribute
|
||||
{
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user