变更
This commit is contained in:
@@ -16,12 +16,6 @@ use Kiri\Di\LocalService;
|
|||||||
use Kiri\Error\{ErrorHandler, StdoutLogger, StdoutLoggerInterface};
|
use Kiri\Error\{ErrorHandler, StdoutLogger, StdoutLoggerInterface};
|
||||||
use Kiri\Exception\{InitException};
|
use Kiri\Exception\{InitException};
|
||||||
use Kiri\Di\ContainerInterface;
|
use Kiri\Di\ContainerInterface;
|
||||||
use Kiri\Message\Constrict\Request;
|
|
||||||
use Kiri\Message\Constrict\RequestInterface;
|
|
||||||
use Kiri\Message\Constrict\Response;
|
|
||||||
use Kiri\Message\Constrict\ResponseInterface;
|
|
||||||
use Kiri\Message\Emitter;
|
|
||||||
use Kiri\Message\ResponseEmitter;
|
|
||||||
use Kiri\Server\{Server};
|
use Kiri\Server\{Server};
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Kiri\Events\EventProvider;
|
use Kiri\Events\EventProvider;
|
||||||
@@ -64,13 +58,15 @@ abstract class BaseMain extends Component
|
|||||||
public function mapping(array $mapping)
|
public function mapping(array $mapping)
|
||||||
{
|
{
|
||||||
$di = Kiri::getDi();
|
$di = Kiri::getDi();
|
||||||
$di->mapping(StdoutLoggerInterface::class, StdoutLogger::class);
|
$di->set(StdoutLoggerInterface::class, StdoutLogger::class);
|
||||||
$di->mapping(LoggerInterface::class, Logger::class);
|
$di->set(LoggerInterface::class, Logger::class);
|
||||||
$di->mapping(Emitter::class, ResponseEmitter::class);
|
|
||||||
$di->mapping(ResponseInterface::class, Response::class);
|
|
||||||
$di->mapping(RequestInterface::class, Request::class);
|
|
||||||
foreach ($mapping as $interface => $class) {
|
foreach ($mapping as $interface => $class) {
|
||||||
$di->mapping($interface, $class);
|
$di->set($interface, $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
$components = Config::get('components', []);
|
||||||
|
foreach ($components as $id => $component) {
|
||||||
|
$this->set($id, $component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ class Main extends BaseMain
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ConfigException
|
|
||||||
*/
|
*/
|
||||||
public function init(): void
|
public function init(): void
|
||||||
{
|
{
|
||||||
@@ -136,10 +135,10 @@ class Main extends BaseMain
|
|||||||
private function argument($argv): array
|
private function argument($argv): array
|
||||||
{
|
{
|
||||||
$input = new ArgvInput($argv);
|
$input = new ArgvInput($argv);
|
||||||
$this->container->setBindings(ArgvInput::class, $input);
|
$this->container->bind(ArgvInput::class, $input);
|
||||||
|
|
||||||
$output = new ConsoleOutput();
|
$output = new ConsoleOutput();
|
||||||
$this->container->setBindings(OutputInterface::class, $output);
|
$this->container->bind(OutputInterface::class, $output);
|
||||||
|
|
||||||
return [$input, $output];
|
return [$input, $output];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user