getConfig(configKey: 'debug'); if ($debug) { $stream = new StreamHandler(stream: dirname(path: __DIR__, levels: 2) . '/bindAPI.log', level: Level::Debug); } else { $stream = new StreamHandler(stream: dirname(path: __DIR__, levels: 2) . '/bindAPI.log', level: Level::Info); } $stream->setFormatter(formatter: $formatter); $this->logger = new Logger(name: 'bindAPI'); $this->logger->pushHandler(handler: $stream); $this->logger->debug(message: 'bindAPI started'); $containerBuilder = new ContainerBuilder(); $containerBuilder->addDefinitions([ ConfigController::class => autowire() ->constructorParameter(parameter: 'quiet', value: $quiet), CLIController::class => autowire() ->constructorParameter(parameter: 'logger', value: $this->logger) ->constructorParameter(parameter: 'quiet', value: $quiet), DomainController::class => autowire() ->constructorParameter(parameter: 'logger', value: $this->logger) ->constructorParameter(parameter: 'quiet', value: $quiet), DomainRepository::class => autowire() ->constructorParameter(parameter: 'logger', value: $this->logger), DynDnsRepository::class => autowire() ->constructorParameter(parameter: 'logger', value: $this->logger), RequestController::class => autowire() ->constructorParameter(parameter: 'logger', value: $this->logger) ]); $this->container = $containerBuilder->build(); } /** * @throws DependencyException * @throws NotFoundException */ public function runCommand(array $arguments): void { $this->logger->debug(message: 'runCommand()'); $cliController = $this->container->get(name: CLIController::class); $cliController->runCommand(arguments: $arguments); } /** * @throws DependencyException * @throws NotFoundException */ public function handleRequest(string $requestMethod, array $uri): void { $this->logger->debug(message: 'handleRequest()'); $requestController = $this->container->get(name: RequestController::class); $requestController->handleRequest(requestMethod: $requestMethod, uri: $uri); } }