@ -62,6 +62,8 @@ class RuleMatcher implements IRuleMatcher {
protected $entity;
/** @var Logger */
protected $logger;
/** @var string */
protected $eventName;
public function __construct(
IUserSession $session,
@ -101,6 +103,13 @@ class RuleMatcher implements IRuleMatcher {
$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');
@ -155,6 +164,11 @@ class RuleMatcher implements IRuleMatcher {
$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);