Skip to content

Commit

Permalink
Issue #56: Extract new method loadSettings().
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed Nov 28, 2024
1 parent 6b25a4d commit 6b73cbb
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/Cool/CollaboraConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ public function __construct(
* that of the current Drupal request.
*/
protected function getWopiClientServerBaseUrl(): string {
$cool_settings = $this->configFactory->get('collabora_online.settings')->get('cool');
if (!$cool_settings) {
throw new CollaboraNotAvailableException('The Collabora Online connection is not configured.');
}
$cool_settings = $this->loadSettings();
$wopi_client_server = $cool_settings['server'] ?? NULL;
if (!$wopi_client_server) {
throw new CollaboraNotAvailableException('The configured Collabora Online server address is empty.');
Expand Down Expand Up @@ -91,10 +88,7 @@ protected function getWopiClientServerBaseUrl(): string {
public function getDiscoveryXml(): string {
$discovery_url = $this->getWopiClientServerBaseUrl() . '/hosting/discovery';

$cool_settings = $this->configFactory->get('collabora_online.settings')->get('cool');
if (!$cool_settings) {
throw new CollaboraNotAvailableException('The Collabora Online connection is not configured.');
}
$cool_settings = $this->loadSettings();
$disable_checks = !empty($cool_settings['disable_cert_check']);

try {
Expand All @@ -118,4 +112,21 @@ public function getDiscoveryXml(): string {
return $xml;
}

/**
* Loads the relevant configuration.
*
* @return array
* Configuration.
*
* @throws \Drupal\collabora_online\Exception\CollaboraNotAvailableException
* The module is not configured.
*/
protected function loadSettings(): array {
$cool_settings = $this->configFactory->get('collabora_online.settings')->get('cool');
if (!$cool_settings) {
throw new CollaboraNotAvailableException('The Collabora Online connection is not configured.');
}
return $cool_settings;
}

}

0 comments on commit 6b73cbb

Please sign in to comment.