private function receiveRemoveWebHook(User $user, ConnectionInterface $from, $msg, $type, $comKey) { $endpoint = $msg['endpoint']; if ($webHook = $this->getWebHook($user, $from, $type, $comKey, $endpoint)) { if ($this->isWebHookRegistered($webHook)) { foreach ($this->getAttachedSocketClients($webHook) as $socketClient) { $this->logger->info("Inform client for the WebHook deletion", ['client' => $socketClient->resourceId, 'endpoint' => $endpoint, 'conn' => $from->resourceId, 'ck' => $comKey]); $this->answer($socketClient, 'forwardRemoveWebHook', rand(100000, 999999), ['endpoint' => $endpoint]); } $this->webHooks->removeElement($webHook); $this->answerOk($from, $type, $comKey); $this->logger->info("WebHook removed", ['endpoint' => $endpoint, 'conn' => $from->resourceId, 'ck' => $comKey]); } else { $this->answerError($from, $type, $comKey, 'WebHook "' . $endpoint . '" was not registered'); } } else { $this->answerError($from, $type, $comKey, '[REMOVE] WebHook was not found'); } }
/** * @param WebHook $webHook */ public function removeWebHook(WebHook $webHook) { $this->webHooks->remove($webHook); $webHook->setUser(null); }