Skip to content

Commit

Permalink
Issue CollaboraOnline#56: Inject CoolRequest as a service in ViewerCo…
Browse files Browse the repository at this point in the history
…ntroller.
  • Loading branch information
donquixote committed Nov 21, 2024
1 parent b77894a commit f0333ec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Controller/ViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ class ViewerController extends ControllerBase {
/**
* The controller constructor.
*
* @param \Drupal\collabora_online\Cool\CoolRequest $coolRequest
* 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 RendererInterface $renderer,
) {}

Expand All @@ -55,10 +58,8 @@ public function editor(Media $media, Request $request, $edit = FALSE) {
'closebutton' => 'true',
];

/** @var \Drupal\collabora_online\Cool\CoolRequest $req */
$req = \Drupal::service(CoolRequest::class);
try {
$wopi_client_url = $req->getWopiClientURL();
$wopi_client_url = $this->coolRequest->getWopiClientURL();
}
catch (CoolRequestException $e) {
$error_msg = $this->t('The Collabora Online server is not available: @message', [
Expand Down

0 comments on commit f0333ec

Please sign in to comment.