Subscription enumeration, tweaks

This commit is contained in:
2024-03-11 14:39:58 +01:00
parent 2747b59abc
commit 8cbd12ee61
6 changed files with 76 additions and 23 deletions

View File

@ -53,6 +53,27 @@ class TopicManager
}
}
public function getSubscriptions(): array
{
$all = [];
foreach ($this->topics as $topic) {
$subs = $topic->getSubscribers();
foreach ($subs as $sub) {
$all[] = [
'id' => './well-known/mercure/subsciptions/'.urlencode($topic->getTopic())."/".urlencode($sub->getId()),
'type' => "Subscription",
'topic' => $topic->getTopic(),
'subscriber' => $sub->getId(),
'active' => true,
'payload' => null,
];
}
}
return $all;
}
public function getTopicCount(): int
{
return count($this->topics);