setFormatter(formatter: $formatter); $this->log = new Logger(name: 'bindAPI'); $this->log->pushHandler(handler: $stream); $containerBuilder = new ContainerBuilder(); $containerBuilder->addDefinitions([ DatabaseConnection::class => autowire()->constructorParameter(parameter: 'config', value: $this->config), DomainController::class => autowire() ->constructorParameter(parameter: 'config', value: $this->config) ->constructorParameter(parameter: 'log', value: $this->log), DomainRepository::class => autowire() ->constructorParameter(parameter: 'config', value: $this->config) ->constructorParameter(parameter: 'log', value: $this->log), ]); $this->container = $containerBuilder->build(); $this->apiController = $this->container->get(name: ApiController::class); $this->domainController = $this->container->get(name: DomainController::class); $this->domainRepository = $this->container->get(name: DomainRepository::class); $this->nameserverRepository = $this->container->get(name: NameserverRepository::class); $this->panelRepository = $this->container->get(name: PanelRepository::class); $this->apikeyRepository = $this->container->get(name: ApikeyRepository::class); } // TODO mode to domainController function isValidSecondLevelDomain(string $domainName, string $panel, int $parent): bool { if ($this->config['debug']) { $this->log->debug(message: "isValidSecondLevelDomain()"); } // subdomain if ($parent != 0) { return false; } // system domain if (str_contains(haystack: $domainName, needle: $panel)) { return false; } // valid second level domain if (!Validator::endsWithTld(value: $domainName)) { return false; } // no second level domain if (substr_count(haystack: $domainName, needle: '.') > 1) { return false; } return true; } /** * @return int|void */ public function getId() { if (!empty($this->arguments[1])) { $id = intval(value: $this->arguments[1] ?? 0); if ($id != $this->arguments[1]) { echo 'ID has to be a number.' . PHP_EOL; exit(1); } } else { $id = 0; } return $id; } }