qqq
This commit is contained in:
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Kiri\Di\Inject;
|
|
||||||
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Kiri\Di\Container;
|
|
||||||
use Kiri\Di\Interface\InjectPropertyInterface;
|
|
||||||
use Kiri\Di\LocalService;
|
|
||||||
|
|
||||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
|
||||||
class Service implements InjectPropertyInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $service
|
|
||||||
*/
|
|
||||||
public function __construct(readonly public string $service)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param object $class
|
|
||||||
* @param string $property
|
|
||||||
* @return void
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function dispatch(object $class, string $property): void
|
|
||||||
{
|
|
||||||
$service = Container::instance()->get(LocalService::class);
|
|
||||||
|
|
||||||
$class->{$property} = $service->get($this->service);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
|
|
||||||
namespace Kiri\Di\Inject;
|
|
||||||
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Kiri\Di\Interface\InjectParameterInterface;
|
|
||||||
use Kiri\Di\LocalService;
|
|
||||||
use Kiri\Di\Container;
|
|
||||||
|
|
||||||
#[\Attribute(\Attribute::TARGET_PARAMETER)]
|
|
||||||
class ServiceParams implements InjectParameterInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param mixed $value
|
|
||||||
*/
|
|
||||||
public function __construct(readonly public mixed $value)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**s
|
|
||||||
* @return mixed|null
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public function dispatch(string $class, string $method): mixed
|
|
||||||
{
|
|
||||||
$service = Container::instance()->get(LocalService::class);
|
|
||||||
|
|
||||||
return $service->get($this->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user