@ -62,6 +62,8 @@ class RuleMatcher implements IRuleMatcher {
protected $entity ;
protected $entity ;
/** @var Logger */
/** @var Logger */
protected $logger ;
protected $logger ;
/** @var string */
protected $eventName ;
public function __construct (
public function __construct (
IUserSession $session ,
IUserSession $session ,
@ -101,6 +103,13 @@ class RuleMatcher implements IRuleMatcher {
$this -> entity = $entity ;
$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 {
public function getEntity () : IEntity {
if ( $this -> entity === null ) {
if ( $this -> entity === null ) {
throw new \LogicException ( 'Entity was not set yet' );
throw new \LogicException ( 'Entity was not set yet' );
@ -155,6 +164,11 @@ class RuleMatcher implements IRuleMatcher {
$matches = [];
$matches = [];
foreach ( $operations as $operation ) {
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 );
$checkIds = json_decode ( $operation [ 'checks' ], true );
$checks = $this -> manager -> getChecks ( $checkIds );
$checks = $this -> manager -> getChecks ( $checkIds );