modify
This commit is contained in:
@@ -21,10 +21,10 @@ use Snowflake\Snowflake;
|
||||
|
||||
/**
|
||||
* Inject constructor.
|
||||
* @param string $className
|
||||
* @param string $value
|
||||
* @param array $args
|
||||
*/
|
||||
public function __construct(private string $className, public bool $withContext = false, private array $args = [])
|
||||
public function __construct(private string $value, public bool $withContext = false, private array $args = [])
|
||||
{
|
||||
}
|
||||
|
||||
@@ -93,14 +93,14 @@ use Snowflake\Snowflake;
|
||||
private function parseInjectValue(): mixed
|
||||
{
|
||||
if ($this->withContext) {
|
||||
return Context::getContext($this->className);
|
||||
return Context::getContext($this->value);
|
||||
}
|
||||
if (class_exists($this->className)) {
|
||||
return Snowflake::getDi()->get($this->className, $this->args);
|
||||
} else if (Snowflake::app()->has($this->className)) {
|
||||
return Snowflake::app()->get($this->className);
|
||||
if (class_exists($this->value)) {
|
||||
return Snowflake::getDi()->get($this->value, $this->args);
|
||||
} else if (Snowflake::app()->has($this->value)) {
|
||||
return Snowflake::app()->get($this->value);
|
||||
} else {
|
||||
return $this->className;
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Annotation\Route;
|
||||
|
||||
|
||||
use Annotation\Attribute;
|
||||
use HttpServer\Route\Middlewares;
|
||||
use HttpServer\Route\MiddlewareManager;
|
||||
use Snowflake\Snowflake;
|
||||
use HttpServer\IInterface\Middleware as IMiddleware;
|
||||
|
||||
@@ -47,7 +47,7 @@ use HttpServer\IInterface\Middleware as IMiddleware;
|
||||
*/
|
||||
public function execute(mixed $class, mixed $method = null): static
|
||||
{
|
||||
$middleware = Snowflake::getDi()->get(Middlewares::class);
|
||||
$middleware = Snowflake::getDi()->get(MiddlewareManager::class);
|
||||
$middleware->addMiddlewares($class, $method, $this->middleware);
|
||||
return $this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user