Skip to content

Commit

Permalink
Issue CollaboraOnline#56: Inject config factory service.
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed Nov 12, 2024
1 parent 09f17b8 commit 94b7ad3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Cool/CoolRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@
namespace Drupal\collabora_online\Cool;

use Drupal\collabora_online\Exception\CoolRequestException;
use Drupal\Core\Config\ConfigFactoryInterface;

/**
* Service to fetch a WOPI client url.
*/
class CoolRequest {

/**
* Constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* Config factory.
*/
public function __construct(
protected readonly ConfigFactoryInterface $configFactory,
) {}

/**
* Gets the URL for the WOPI client.
*
Expand All @@ -30,7 +41,7 @@ class CoolRequest {
*/
public function getWopiClientURL(): string {
$_HOST_SCHEME = isset($_SERVER['HTTPS']) ? 'https' : 'http';
$default_config = \Drupal::config('collabora_online.settings');
$default_config = $this->configFactory->get('collabora_online.settings');
$wopi_client_server = $default_config->get('cool')['server'];
if (!$wopi_client_server) {
throw new CoolRequestException(
Expand Down Expand Up @@ -93,7 +104,7 @@ public function getWopiClientURL(): string {
protected function getDiscovery(string $server): string|false {
$discovery_url = $server . '/hosting/discovery';

$default_config = \Drupal::config('collabora_online.settings');
$default_config = $this->configFactory->get('collabora_online.settings');
if ($default_config === NULL) {
return FALSE;
}
Expand Down

0 comments on commit 94b7ad3

Please sign in to comment.