Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/workflowengine/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function ($event) use ($eventName, $operationClass, $entityClass) {
/** @var IOperation $operation */
$operation = $this->getContainer()->query($operationClass);

$ruleMatcher->setEventName($eventName);
$ruleMatcher->setEntity($entity);
$ruleMatcher->setOperation($operation);

Expand Down
14 changes: 14 additions & 0 deletions apps/workflowengine/lib/Service/RuleMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class RuleMatcher implements IRuleMatcher {
protected $entity;
/** @var Logger */
protected $logger;
/** @var string */
protected $eventName;

public function __construct(
IUserSession $session,
Expand Down Expand Up @@ -100,6 +102,13 @@ public function setEntity(IEntity $entity): void {
$this->entity = $entity;
}

public function setEventName(string $eventName): void {
if ($this->eventName !== null) {
throw new RuntimeException('This method must not be called more than once');
}
$this->eventName = $eventName;
}

public function getEntity(): IEntity {
if($this->entity === null) {
throw new \LogicException('Entity was not set yet');
Expand Down Expand Up @@ -154,6 +163,11 @@ public function getMatchingOperations(string $class, bool $returnFirstMatchingOp

$matches = [];
foreach ($operations as $operation) {
$configuredEvents = json_decode($operation['events'], true);
if ($this->eventName !== null && !in_array($this->eventName, $configuredEvents)) {
continue;
}

$checkIds = json_decode($operation['checks'], true);
$checks = $this->manager->getChecks($checkIds);

Expand Down
10 changes: 10 additions & 0 deletions lib/public/WorkflowEngine/IRuleMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,14 @@ public function setEntity(IEntity $entity): void;
* @since 18.0.0
*/
public function getEntity(): IEntity;

/**
* this method can be called once to set the event name that is currently
* being processed. The workflow engine takes care of this usually, only an
* IComplexOperation might want to make use of it.
*
* @throws RuntimeException
* @since 18.0.9
*/
public function setEventName(string $eventName): void;
}