变更
This commit is contained in:
+27
-6
@@ -11,10 +11,13 @@ use Psr\Http\Message\RequestInterface;
|
|||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Kiri\Di\Inject\Service;
|
use Kiri\Di\Inject\Service;
|
||||||
use Kiri\Di\Inject\Container;
|
use Kiri\Di\Inject\Container;
|
||||||
|
use ReflectionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class WebController
|
* Class WebController
|
||||||
* @package Kiri\Web
|
* @package Kiri\Web
|
||||||
|
* @property-read ContainerInterface $container
|
||||||
|
* @property-read LoggerInterface $logger
|
||||||
*/
|
*/
|
||||||
abstract class Controller
|
abstract class Controller
|
||||||
{
|
{
|
||||||
@@ -35,15 +38,33 @@ abstract class Controller
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var LoggerInterface
|
* @return ContainerInterface
|
||||||
*/
|
*/
|
||||||
#[Container(LoggerInterface::class)]
|
private function getContainer(): ContainerInterface
|
||||||
public LoggerInterface $logger;
|
{
|
||||||
|
return Kiri::getDi();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ContainerInterface
|
* @return LoggerInterface
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
#[Container(ContainerInterface::class)]
|
private function getLogger(): LoggerInterface
|
||||||
public ContainerInterface $container;
|
{
|
||||||
|
return Kiri::getDi()->get(LoggerInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function __get(string $name)
|
||||||
|
{
|
||||||
|
// TODO: Implement __get() method.
|
||||||
|
return $this->{'get' . ucfirst($name)}();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user