From 3ea0f2b0ff70e15dbb9238939a20bd94c3621080 Mon Sep 17 00:00:00 2001 From: Robert Landers Date: Sun, 14 Jan 2024 13:42:25 +0100 Subject: [PATCH] accept an entity id --- src/OrchestrationContext.php | 4 ++-- src/OrchestrationContextInterface.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OrchestrationContext.php b/src/OrchestrationContext.php index 6bfd9678..ab002d7a 100644 --- a/src/OrchestrationContext.php +++ b/src/OrchestrationContext.php @@ -466,7 +466,7 @@ public static function reset(){ }; } - public function entityOp(string $id, \Closure $operation): mixed + public function entityOp(string|EntityId $id, \Closure $operation): mixed { $func = new \ReflectionFunction($operation); if($func->getNumberOfParameters() !== 1) { @@ -498,7 +498,7 @@ public function entityOp(string $id, \Closure $operation): mixed throw new LogicException('Did not call an operation'); } - $entityId = new EntityId($name, $id); + $entityId = $id instanceof EntityId ? $id : new EntityId($name, $id); if($returns) { return $this->waitOne($this->callEntity($entityId, $operationName, $arguments)); diff --git a/src/OrchestrationContextInterface.php b/src/OrchestrationContextInterface.php index a93f4d91..6efb4380 100644 --- a/src/OrchestrationContextInterface.php +++ b/src/OrchestrationContextInterface.php @@ -70,11 +70,11 @@ public function signalEntity(EntityId $entityId, string $operation, array $args /** * @template T * @template V - * @param string $id + * @param string|EntityId $id * @param \Closure(T): V $operation * @return V */ - public function entityOp(string $id, \Closure $operation): mixed; + public function entityOp(string|EntityId $id, \Closure $operation): mixed; /** * Determines if an entity is locked. Returns true if the entity is locked.