改名
This commit is contained in:
@@ -212,24 +212,47 @@ class Annotation extends Component
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$name = get_class($object) . '_' . $method->getName();
|
||||||
|
if (!isset($this->_annotations[$alias])) {
|
||||||
|
$this->_annotations[$alias] = [];
|
||||||
|
}
|
||||||
|
if (!isset($this->_annotations[$alias][$name])) {
|
||||||
|
$this->_annotations[$alias][$name] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$array = [];
|
||||||
foreach ($attributes as $attribute) {
|
foreach ($attributes as $attribute) {
|
||||||
/** @var IAnnotation $class */
|
/** @var IAnnotation $class */
|
||||||
$class = $this->instance($attribute);
|
$class = $this->instance($attribute);
|
||||||
if ($class === null) {
|
if ($class === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$class->execute([$object, $method->getName()]);
|
$array[] = $class->execute([$object, $method->getName()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $tmp['handler'] = [$object, $method->getName()];
|
$this->_annotations[$alias][$name][] = $array;
|
||||||
// $tmp['attributes'] = $names;
|
|
||||||
//
|
|
||||||
// $this->_annotations[$alias][] = $tmp;
|
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $class
|
||||||
|
* @param $method
|
||||||
|
* @param string $alias
|
||||||
|
* @return array|mixed
|
||||||
|
*/
|
||||||
|
public function getAnnotationByMethod($class, $method, $alias = '')
|
||||||
|
{
|
||||||
|
if (!isset($this->_annotations[$alias])) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (is_object($class)) {
|
||||||
|
$class = get_class($class);
|
||||||
|
}
|
||||||
|
return $this->_annotations[$alias][$class . '_' . $method] ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $className
|
* @param $className
|
||||||
* @param string $method
|
* @param string $method
|
||||||
|
|||||||
@@ -34,16 +34,10 @@ use Snowflake\Snowflake;
|
|||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param array $handler
|
||||||
* @return array|string
|
* @return array|string
|
||||||
* @throws ReflectionException
|
|
||||||
* @throws NotFindClassException
|
|
||||||
*/
|
*/
|
||||||
public function execute(array $handler): array|string
|
public function execute(array $handler): array|string
|
||||||
{
|
{
|
||||||
// TODO: Implement execute() method.
|
return $this;
|
||||||
foreach ($this->after as $key => $item) {
|
|
||||||
$this->after[$key] = [Snowflake::createObject($item), 'onHandler'];
|
|
||||||
}
|
|
||||||
return $this->after;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,16 +34,10 @@ use Snowflake\Snowflake;
|
|||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param array $handler
|
||||||
* @return array|string
|
* @return array|string
|
||||||
* @throws ReflectionException
|
|
||||||
* @throws NotFindClassException
|
|
||||||
*/
|
*/
|
||||||
public function execute(array $handler): array|string
|
public function execute(array $handler): array|string
|
||||||
{
|
{
|
||||||
// TODO: Implement execute() method.
|
return $this;
|
||||||
foreach ($this->interceptor as $key => $item) {
|
|
||||||
$this->interceptor[$key] = [Snowflake::createObject($item), 'Interceptor'];
|
|
||||||
}
|
|
||||||
return $this->interceptor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,16 +34,10 @@ use Snowflake\Snowflake;
|
|||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param array $handler
|
||||||
* @return array|string
|
* @return array|string
|
||||||
* @throws ReflectionException
|
|
||||||
* @throws NotFindClassException
|
|
||||||
*/
|
*/
|
||||||
public function execute(array $handler): array|string
|
public function execute(array $handler): array|string
|
||||||
{
|
{
|
||||||
// TODO: Implement execute() method.
|
return $this;
|
||||||
foreach ($this->limits as $key => $item) {
|
|
||||||
$this->limits[$key] = [Snowflake::createObject($item), 'next'];
|
|
||||||
}
|
|
||||||
return $this->limits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,16 +35,10 @@ use Snowflake\Snowflake;
|
|||||||
/**
|
/**
|
||||||
* @param array $handler
|
* @param array $handler
|
||||||
* @return array|string
|
* @return array|string
|
||||||
* @throws ReflectionException
|
|
||||||
* @throws NotFindClassException
|
|
||||||
*/
|
*/
|
||||||
public function execute(array $handler): array|string
|
public function execute(array $handler): array|string
|
||||||
{
|
{
|
||||||
// TODO: Implement execute() method.
|
return $this;
|
||||||
foreach ($this->middleware as $key => $item) {
|
|
||||||
$this->middleware[$key] = [Snowflake::createObject($item), 'onHandler'];
|
|
||||||
}
|
|
||||||
return $this->middleware;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ use Annotation\IAnnotation;
|
|||||||
// TODO: Implement setHandler() method.
|
// TODO: Implement setHandler() method.
|
||||||
$router = Snowflake::app()->getRouter();
|
$router = Snowflake::app()->getRouter();
|
||||||
|
|
||||||
var_dump($this->uri, $handler, $this->method);
|
|
||||||
$router->addRoute($this->uri, $handler, $this->method);
|
$router->addRoute($this->uri, $handler, $this->method);
|
||||||
|
|
||||||
return $router;
|
return $router;
|
||||||
|
|||||||
@@ -72,15 +72,11 @@ class Middleware
|
|||||||
}
|
}
|
||||||
[$controller, $action] = $node->handler;
|
[$controller, $action] = $node->handler;
|
||||||
$attributes = Snowflake::app()->getAttributes();
|
$attributes = Snowflake::app()->getAttributes();
|
||||||
$annotation = $attributes->getByClass(get_class($controller), $action);
|
$annotation = $attributes->getAnnotationByMethod($controller, $action, 'controllers');
|
||||||
if (count($annotation) < 1) {
|
if (count($annotation) < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach ($annotation as $item) {
|
foreach ($annotation as $attribute) {
|
||||||
if (empty($item) || !isset($item['attributes'])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
foreach ($item['attributes'] as $attribute) {
|
|
||||||
if ($attribute instanceof Interceptor) {
|
if ($attribute instanceof Interceptor) {
|
||||||
$node->addInterceptor($attribute->interceptor);
|
$node->addInterceptor($attribute->interceptor);
|
||||||
}
|
}
|
||||||
@@ -95,7 +91,6 @@ class Middleware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -447,6 +447,9 @@ class Node extends HttpService
|
|||||||
if (empty($this->handler)) {
|
if (empty($this->handler)) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
if (!is_array($this->handler)) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
/** @var Middleware $made */
|
/** @var Middleware $made */
|
||||||
$made = Snowflake::createObject(Middleware::class);
|
$made = Snowflake::createObject(Middleware::class);
|
||||||
$made->getGenerate($this);
|
$made->getGenerate($this);
|
||||||
|
|||||||
Reference in New Issue
Block a user