改名
This commit is contained in:
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Annotation;
|
||||||
|
|
||||||
|
|
||||||
|
use ReflectionException;
|
||||||
|
use Snowflake\Exception\ComponentException;
|
||||||
|
use Snowflake\Exception\NotFindClassException;
|
||||||
|
use Snowflake\Snowflake;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class LocalService
|
||||||
|
* @package Annotation
|
||||||
|
*/
|
||||||
|
#[\Attribute(\Attribute::TARGET_CLASS)] class LocalService extends Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LocalService constructor.
|
||||||
|
* @param string $service
|
||||||
|
* @param array $args
|
||||||
|
*/
|
||||||
|
public function __construct(public string $service, public array $args = [])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $handler
|
||||||
|
* @return mixed
|
||||||
|
* @throws ReflectionException
|
||||||
|
* @throws ComponentException
|
||||||
|
* @throws NotFindClassException
|
||||||
|
*/
|
||||||
|
public function execute(array $handler): mixed
|
||||||
|
{
|
||||||
|
$class = ['class' => get_class($handler[0])];
|
||||||
|
if (!empty($this->args)) {
|
||||||
|
$class = array_merge($class, $this->args);
|
||||||
|
}
|
||||||
|
|
||||||
|
Snowflake::set($this->service, $class);
|
||||||
|
|
||||||
|
return parent::execute($handler); // TODO: Change the autogenerated stub
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -56,6 +56,20 @@ class Snowflake
|
|||||||
static::$service = $service;
|
static::$service = $service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $alias
|
||||||
|
* @param array $array
|
||||||
|
* @return mixed
|
||||||
|
* @throws ComponentException
|
||||||
|
* @throws NotFindClassException
|
||||||
|
* @throws ReflectionException
|
||||||
|
*/
|
||||||
|
public static function set($alias, $array = []): mixed
|
||||||
|
{
|
||||||
|
return static::app()->set($alias, $array);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Application|null
|
* @return Application|null
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user