Bugfix topicmanager
* Unsubscribing wouldn't always remove the subscriber.
This commit is contained in:
parent
2cbc41d29e
commit
d310060309
@ -33,14 +33,15 @@ class TopicManager
|
||||
|
||||
public function subscribe(SubscriberInterface $subscriber, array $topics): void
|
||||
{
|
||||
$this->subscribers->attach($subscriber);
|
||||
foreach ($topics as $topic) {
|
||||
$this->getTopic($topic)->addSubscriber($subscriber);
|
||||
}
|
||||
$this->subscribers->attach($subscriber);
|
||||
}
|
||||
|
||||
public function unsubscribe(SubscriberInterface $subscriber, ?array $topics=null): void
|
||||
{
|
||||
$this->subscribers->detach($subscriber);
|
||||
if (!$topics) {
|
||||
foreach ($this->topics as $topic) {
|
||||
$topic->removeSubscriber($subscriber);
|
||||
@ -50,7 +51,6 @@ class TopicManager
|
||||
foreach ($topics as $topic) {
|
||||
$this->getTopic($topic)->removeSubscriber($subscriber);
|
||||
}
|
||||
$this->subscribers->detach($subscriber);
|
||||
}
|
||||
|
||||
public function getTopicCount(): int
|
||||
|
Loading…
Reference in New Issue
Block a user