metadata = $metadata; $this->service = $service; $this->user = $user; $this->config = $config; } public function getActionRead(): stdClass { return $this->getConfigData(); } public function putActionUpdate(Request $request): stdClass { if (!$this->user->isAdmin()) { throw new Forbidden(); } $data = $request->getParsedBody(); $this->service->setConfigData($data); return $this->getConfigData(); } public function postActionTestLdapConnection(Request $request): bool { if (!$this->user->isAdmin()) { throw new Forbidden(); } $data = $request->getParsedBody(); if (!isset($data->password)) { $data->password = $this->config->get('ldapPassword'); } $ldapUtils = new LDAPUtils(); $options = $ldapUtils->normalizeOptions( get_object_vars($data) ); $ldapClient = new LDAPClient($options); // An exception thrown if no connection. $ldapClient->bind(); return true; } private function getConfigData(): stdClass { $data = $this->service->getConfigData(); $data->jsLibs = $this->metadata->get(['app', 'jsLibs']); unset($data->loginView); $loginView = $this->metadata->get(['clientDefs', 'App', 'loginView']); if ($loginView) { $data->loginView = $loginView; } return $data; } }