50 lines
938 B
PHP
50 lines
938 B
PHP
<?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
|
|
}
|
|
|
|
}
|