private function registerRuleListeners(IEventDispatcher $dispatcher,
IServerContainer $container,
ILogger $logger): void {
+ /** @var Manager $manager */
$manager = $container->query(Manager::class);
$configuredEvents = $manager->getAllConfiguredEvents();
/** @var IOperation $operation */
$operation = $container->query($operationClass);
+ $ruleMatcher->setEventName($eventName);
$ruleMatcher->setEntity($entity);
$ruleMatcher->setOperation($operation);
protected $entity;
/** @var Logger */
protected $logger;
+ /** @var string */
+ protected $eventName;
public function __construct(
IUserSession $session,
$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');
$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);
* @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 20.0.0
+ */
+ public function setEventName(string $eventName): void;
}