Nextcloud PHP API (master)

IOperation

Interface IOperation

Tags
since
9.1

Table of Contents

Methods

getDescription()  : string
returns a translated, descriptive text to be presented in the web interface.
getDisplayName()  : string
returns a translated name to be presented in the web interface
getIcon()  : string
returns the URL to the icon of the operator for display in the web interface.
isAvailableForScope()  : bool
returns whether the operation can be used in the requested scope.
onEvent()  : void
Is being called by the workflow engine when an event was triggered that is configured for this operation. An evaluation whether the event qualifies for this operation to run has still to be done by the implementor by calling the RuleMatchers getMatchingOperations method and evaluating the results.
validateOperation()  : void
Validates whether a configured workflow rule is valid. If it is not, an `\UnexpectedValueException` is supposed to be thrown.

Methods

getDescription()

returns a translated, descriptive text to be presented in the web interface.

public getDescription() : string

It should be short and precise.

Example: "Tag based automatic deletion of files after a given time." (en)

Tags
since
18.0.0
Return values
string

getDisplayName()

returns a translated name to be presented in the web interface

public getDisplayName() : string

Example: "Automated tagging" (en), "Aŭtomata etikedado" (eo)

Tags
since
18.0.0
Return values
string

getIcon()

returns the URL to the icon of the operator for display in the web interface.

public getIcon() : string

Usually, the implementation would utilize the imagePath() method of the \OCP\IURLGenerator instance and simply return its result.

Example implementation: return $this->urlGenerator->imagePath('myApp', 'cat.svg');

Tags
since
18.0.0
Return values
string

isAvailableForScope()

returns whether the operation can be used in the requested scope.

public isAvailableForScope(int $scope) : bool

Scope IDs are defined as constants in OCP\WorkflowEngine\IManager. At time of writing these are SCOPE_ADMIN and SCOPE_USER.

For possibly unknown future scopes the recommended behaviour is: if user scope is permitted, the default behaviour should return true, otherwise false.

Parameters
$scope : int
Tags
psalm-param

IManager::SCOPE_* $scope

since
18.0.0
Return values
bool

onEvent()

Is being called by the workflow engine when an event was triggered that is configured for this operation. An evaluation whether the event qualifies for this operation to run has still to be done by the implementor by calling the RuleMatchers getMatchingOperations method and evaluating the results.

public onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher) : void

If the implementor is an IComplexOperation, this method will not be called automatically. It can be used or left as no-op by the implementor.

Parameters
$eventName : string
$event : Event
$ruleMatcher : IRuleMatcher
Tags
since
18.0.0

validateOperation()

Validates whether a configured workflow rule is valid. If it is not, an `\UnexpectedValueException` is supposed to be thrown.

public validateOperation(string $name, array<string|int, mixed> $checks, string $operation) : void
Parameters
$name : string
$checks : array<string|int, mixed>
$operation : string
Tags
throws
UnexpectedValueException
since
9.1

        
On this page

Search results