Skip to content

Commit

Permalink
[FIX] missing Null Action
Browse files Browse the repository at this point in the history
  • Loading branch information
chfsx committed Dec 6, 2024
1 parent 6db1ce9 commit 851de8f
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Modules/File/classes/class.ilObjFileGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function executeCommand(): void
$action = match ($capability->getCapability()) {
Capabilities::VIEW_EXTERNAL => $this->action_repo->getViewActionForSuffix($suffix),
Capabilities::EDIT_EXTERNAL => $this->action_repo->getEditActionForSuffix($suffix),
default => null
default => $this->action_repo->null()
};

$this->tabs_gui->activateTab('content');
Expand Down
9 changes: 9 additions & 0 deletions Services/WOPI/classes/Discovery/ActionDBRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ private function implodeTargets(ActionTarget ...$targets): string
);
}

/**
* @description this is only for cases where you need an action (for compatibility), this action cannot be used
* for any WOPI capability
*/
public function null(): NullAction
{
return new NullAction();
}

public function hasActionForSuffix(
string $suffix,
ActionTarget ...$action_target
Expand Down
70 changes: 70 additions & 0 deletions Services/WOPI/classes/Discovery/NullAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\Services\WOPI\Discovery;

use ILIAS\Data\URI;

/**
* @author Fabian Schmid <[email protected]>
*/
class NullAction extends Action
{
/** @noinspection MagicMethodsValidityInspection */
public function __construct()
{
}

public function withId(int $id): self
{
return $this;
}

public function getId(): int
{
return 0;
}

public function getName(): string
{
return 'Null';
}

public function getExtension(): string
{
return '';
}

public function getLauncherUrl(): URI
{
return new URI(''); // this will fail, but a NullAction can't be used anyway
}

public function getUrlAppendix(): ?string
{
return null;
}

public function getTargetExtension(): ?string
{
return null;
}

}

0 comments on commit 851de8f

Please sign in to comment.