added DomainController

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-02-22 16:34:29 +01:00
parent 9c87d47477
commit 7e5810a936
1 changed files with 7 additions and 4 deletions

View File

@ -50,7 +50,7 @@ class RequestController
{ {
private Logger $log; private Logger $log;
//private DatabaseConnection $databaseConnection; private DomainController $domainController;
private DomainRepository $domainRepository; private DomainRepository $domainRepository;
private ApikeyRepository $apikeyRepository; private ApikeyRepository $apikeyRepository;
private Container $container; private Container $container;
@ -85,6 +85,9 @@ class RequestController
$containerBuilder = new ContainerBuilder(); $containerBuilder = new ContainerBuilder();
$containerBuilder->addDefinitions([ $containerBuilder->addDefinitions([
DatabaseConnection::class => autowire()->constructorParameter(parameter: 'config', value: $this->config), 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() DomainRepository::class => autowire()
->constructorParameter(parameter: 'config', value: $this->config) ->constructorParameter(parameter: 'config', value: $this->config)
->constructorParameter(parameter: 'log', value: $this->log), ->constructorParameter(parameter: 'log', value: $this->log),
@ -92,6 +95,7 @@ class RequestController
]); ]);
$this->container = $containerBuilder->build(); $this->container = $containerBuilder->build();
$this->domainController = $this->container->get(name: DomainController::class);
$this->domainRepository = $this->container->get(name: DomainRepository::class); $this->domainRepository = $this->container->get(name: DomainRepository::class);
$this->apikeyRepository = $this->container->get(name: ApikeyRepository::class); $this->apikeyRepository = $this->container->get(name: ApikeyRepository::class);
@ -356,8 +360,7 @@ class RequestController
/** /**
* @return void * @return void
*/ */
public public function handleDomainPostRequest(): void
function handleDomainPostRequest(): void
{ {
$name = $_POST['name'] ?? ''; $name = $_POST['name'] ?? '';
$panel = $_POST['panel'] ?? ''; $panel = $_POST['panel'] ?? '';
@ -417,12 +420,12 @@ class RequestController
$this->status = "404 Not Found"; $this->status = "404 Not Found";
$this->message = "Domain with ID : $id doesn't exist."; $this->message = "Domain with ID : $id doesn't exist.";
} else { } else {
// TODO not required, as we rely on the ID
$domain = new Domain(name: $name, panel: $panel, id: $id); $domain = new Domain(name: $name, panel: $panel, id: $id);
$this->domainRepository->update(domain: $domain); $this->domainRepository->update(domain: $domain);
$this->header = "201 Updated"; $this->header = "201 Updated";
$this->status = "201 Updated"; $this->status = "201 Updated";
$this->message = "201 Updated"; $this->message = "201 Updated";
$this->domainController->createSlaveZoneFile(domain: $domain);
} }
} }
} }