Nextcloud PHP API (stable18)

IComplexOperation extends IOperation

Interface IComplexOperation

This interface represents an operator that is less generic and indicates that some of the tasks it does itself instead of relying on the engine. This includes:

  • registering listeners – the implementing app needs to ensure that the business logic registers listeners to the events it listens to. For example when direct storage access is required, adding a wrapper or listening to a specific one is required over usual file events.
Tags
since
18.0.0

Table of Contents

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.
getTriggerHint()  : string
As IComplexOperation chooses the triggering events itself, a hint has to be shown to the user so make clear when this operation is becoming active. This method returns such a translated string.
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

getTriggerHint()

As IComplexOperation chooses the triggering events itself, a hint has to be shown to the user so make clear when this operation is becoming active. This method returns such a translated string.

public getTriggerHint() : string

Example: "When a file is accessed" (en)

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
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 $checks, string $operation) : void
Parameters
$name : string
$checks : array
$operation : string
Tags
throws
UnexpectedValueException
since
9.1

Search results