federatedEventService = $federatedEventService; $this->circleService = $circleService; } /** * @param string $circleId * @param string $itemId * * @return FederatedShare * @throws FederatedEventDSyncException * @throws FederatedEventException * @throws FederatedItemException * @throws FederatedShareAlreadyLockedException * @throws InitiatorNotConfirmedException * @throws InvalidItemException * @throws OwnerNotFoundException * @throws RemoteNotFoundException * @throws RemoteResourceNotFoundException * @throws RequestNetworkException * @throws SignatoryException * @throws UnknownRemoteException * @throws UnknownTypeException * @throws CircleNotFoundException * @throws InitiatorNotFoundException */ public function lockItem(string $circleId, string $itemId): FederatedShare { $circle = $this->circleService->getCircle($circleId); $event = new FederatedEvent(ItemLock::class); $event->setCircle($circle); $event->getData()->s('itemId', $itemId); $data = $this->federatedEventService->newEvent($event); /** @var FederatedShare $share */ $share = $data->gObj('federatedShare', FederatedShare::class); if ($share->getLockStatus() === ItemLock::STATUS_INSTANCE_LOCKED) { throw new FederatedShareAlreadyLockedException('item already locked by ' . $share->getInstance()); } return $share; } }