改名
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
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user