Skip to content

Commit

Permalink
Issue #56: Call getWopiClientServerBaseUrl() directly from getDiscove…
Browse files Browse the repository at this point in the history
…ry().
  • Loading branch information
donquixote committed Dec 3, 2024
1 parent f09af44 commit 3191945
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/Cool/CollaboraDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public function __construct(
* The client url cannot be retrieved.
*/
public function getWopiClientURL(string $mimetype = 'text/plain'): string {
$wopi_client_server = $this->discoveryFetcher->getWopiClientServerBaseUrl();
$xml = $this->discoveryFetcher->getDiscoveryXml($wopi_client_server);
$xml = $this->discoveryFetcher->getDiscoveryXml();

$discovery_parsed = simplexml_load_string($xml);
if (!$discovery_parsed) {
Expand Down
11 changes: 3 additions & 8 deletions src/Cool/CollaboraDiscoveryFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,14 @@ public function __construct(
/**
* Gets the contents of discovery.xml from the Collabora server.
*
* @param string $server
* Url of the Collabora Online server.
*
* @return string
* The full contents of discovery.xml.
*
* @throws \Drupal\collabora_online\Exception\CollaboraNotAvailableException
* The client url cannot be retrieved.
*/
public function getDiscoveryXml(string $server): string {
$discovery_url = $server . '/hosting/discovery';
public function getDiscoveryXml(): string {
$discovery_url = $this->getWopiClientServerBaseUrl() . '/hosting/discovery';

$cool_settings = $this->loadSettings();
$disable_checks = (bool) $cool_settings['disable_cert_check'];
Expand Down Expand Up @@ -88,10 +85,8 @@ public function getDiscoveryXml(string $server): string {
* @throws \Drupal\collabora_online\Exception\CollaboraNotAvailableException
* The WOPI server url is misconfigured, or the protocol does not match
* that of the current Drupal request.
*
* @todo Make this protected, only call from within.
*/
public function getWopiClientServerBaseUrl(): string {
protected function getWopiClientServerBaseUrl(): string {
$cool_settings = $this->loadSettings();
$wopi_client_server = $cool_settings['server'];
if (!$wopi_client_server) {
Expand Down

0 comments on commit 3191945

Please sign in to comment.