Skip to content

Commit

Permalink
Issue CollaboraOnline#56: Rename CoolRequest to CollaboraDiscovery.
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed Nov 21, 2024
1 parent 864188d commit beaf9d9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion collabora_online.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ services:
parent: logger.channel_base
arguments: ['cool']
Drupal\collabora_online\Cool\CoolDiscoveryXmlEndpoint: { }
Drupal\collabora_online\Cool\CoolRequest: { }
Drupal\collabora_online\Cool\CollaboraDiscovery: { }
8 changes: 4 additions & 4 deletions src/Controller/ViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Drupal\collabora_online\Controller;

use Drupal\collabora_online\Cool\CoolRequest;
use Drupal\collabora_online\Cool\CollaboraDiscovery;
use Drupal\collabora_online\Cool\CoolUtils;
use Drupal\collabora_online\Exception\CoolRequestException;
use Drupal\Core\Controller\ControllerBase;
Expand All @@ -29,13 +29,13 @@ class ViewerController extends ControllerBase {
/**
* The controller constructor.
*
* @param \Drupal\collabora_online\Cool\CoolRequest $coolRequest
* @param \Drupal\collabora_online\Cool\CollaboraDiscovery $discovery
* Service to fetch a WOPI client url.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer service.
*/
public function __construct(
protected readonly CoolRequest $coolRequest,
protected readonly CollaboraDiscovery $discovery,
protected readonly RendererInterface $renderer,
) {}

Expand All @@ -59,7 +59,7 @@ public function editor(Media $media, Request $request, $edit = FALSE) {
];

try {
$wopi_client_url = $this->coolRequest->getWopiClientURL();
$wopi_client_url = $this->discovery->getWopiClientURL();
}
catch (CoolRequestException $e) {
$error_msg = $this->t('The Collabora Online server is not available: @message', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Service to fetch a WOPI client url.
*/
class CoolRequest {
class CollaboraDiscovery {

/**
* Constructor.
Expand Down
14 changes: 7 additions & 7 deletions tests/src/ExistingSite/FetchClientUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Drupal\Tests\collabora_online\ExistingSite;

use Drupal\collabora_online\Cool\CoolRequest;
use Drupal\collabora_online\Cool\CollaboraDiscovery;
use Drupal\collabora_online\Exception\CoolRequestException;
use weitzman\DrupalTestTraits\ExistingSiteBase;

Expand All @@ -17,9 +17,9 @@ class FetchClientUrlTest extends ExistingSiteBase {
* Tests fetching the client url.
*/
public function testFetchClientUrl(): void {
/** @var \Drupal\collabora_online\Cool\CoolRequest $cool_request */
$cool_request = \Drupal::service(CoolRequest::class);
$client_url = $cool_request->getWopiClientURL();
/** @var \Drupal\collabora_online\Cool\CollaboraDiscovery $discovery */
$discovery = \Drupal::service(CollaboraDiscovery::class);
$client_url = $discovery->getWopiClientURL();
// The protocol, domain and port are known when this test runs in the
// docker-compose setup.
$this->assertMatchesRegularExpression('@^http://collabora\.test:9980/browser/[0-9a-f]+/cool\.html\?$@', $client_url);
Expand All @@ -36,13 +36,13 @@ public function testFetchClientUrlWithMisconfiguration(): void {
'server' => 'httx://example.com',
],
]);
/** @var \Drupal\collabora_online\Cool\CoolRequest $cool_request */
$cool_request = \Drupal::service(CoolRequest::class);
/** @var \Drupal\collabora_online\Cool\CollaboraDiscovery $discovery */
$discovery = \Drupal::service(CollaboraDiscovery::class);

$this->expectException(CoolRequestException::class);
$this->expectExceptionMessage("The configured Collabora Online server address must begin with 'http://' or 'https://'. Found 'httx://example.com'.");

$cool_request->getWopiClientURL();
$discovery->getWopiClientURL();
}

}

0 comments on commit beaf9d9

Please sign in to comment.