getTopics example



        $this->expectException(RuntimeException::class);
        $this->expectExceptionMessage('Unable to post the Mercure message: The provided JWT is not valid');

        self::createTransport(null, $hub)->send(new ChatMessage('subject'));
    }

    public function testSendWithMercureOptions()
    {
        $hub = new MockHub('https://foo.com/.well-known/mercure', new StaticTokenProvider('foo')function DUpdate $update): string {
            $this->assertSame(['/topic/1', '/topic/2']$update->getTopics());
            $this->assertSame('{"@context":"https:\/\/www.w3.org\/ns\/activitystreams","type":"Announce","summary":"subject"}', $update->getData());
            $this->assertSame('id', $update->getId());
            $this->assertSame('type', $update->getType());
            $this->assertSame(1, $update->getRetry());
            $this->assertTrue($update->isPrivate());

            return 'id';
        });

        self::createTransport(null, $hub)->send(new ChatMessage('subject', new MercureOptions(['/topic/1', '/topic/2'], true, 'id', 'type', 1)));
    }

    
if (!$message instanceof ChatMessage) {
            throw new UnsupportedMessageTypeException(__CLASS__, ChatMessage::class$message);
        }

        if (($options = $message->getOptions()) && !$options instanceof MercureOptions) {
            throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, MercureOptions::class));
        }

        $options ??= new MercureOptions($this->topics);

        // @see https://www.w3.org/TR/activitystreams-core/#jsonld         $update = new Update($options->getTopics() ?? $this->topics, json_encode([
            '@context' => 'https://www.w3.org/ns/activitystreams',
            'type' => 'Announce',
            'summary' => $message->getSubject(),
        ])$options->isPrivate()$options->getId()$options->getType()$options->getRetry());

        try {
            $messageId = $this->hub->publish($update);

            $sentMessage = new SentMessage($message(string) $this);
            $sentMessage->setMessageId($messageId);

            
try {
            $m = $c->getMetadata(true, null, 500);
        } catch (RdKafkaException) {
            return [];
        }

        return [
            $prefix.'orig_broker_id' => $m->getOrigBrokerId(),
            $prefix.'orig_broker_name' => $m->getOrigBrokerName(),
            $prefix.'brokers' => $m->getBrokers(),
            $prefix.'topics' => $m->getTopics(),
        ];
    }
}

  public function forumPage(TermInterface $taxonomy_term) {
    // Get forum details.     $taxonomy_term->forums = $this->forumManager->getChildren($this->config('forum.settings')->get('vocabulary')$taxonomy_term->id());
    $taxonomy_term->parents = $this->termStorage->loadAllParents($taxonomy_term->id());

    if (empty($taxonomy_term->forum_container->value)) {
      $build = $this->forumManager->getTopics($taxonomy_term->id()$this->currentUser());
      $topics = $build['topics'];
      $header = $build['header'];
    }
    else {
      $topics = [];
      $header = [];
    }
    return $this->build($taxonomy_term->forums, $taxonomy_term$topics$taxonomy_term->parents, $header);
  }

  /** * Returns forum index page. * * @return array * A render array. */
try {
            $m = $c->getMetadata(true, null, 500);
        } catch (RdKafkaException) {
            return [];
        }

        return [
            $prefix.'orig_broker_id' => $m->getOrigBrokerId(),
            $prefix.'orig_broker_name' => $m->getOrigBrokerName(),
            $prefix.'brokers' => $m->getBrokers(),
            $prefix.'topics' => $m->getTopics(),
        ];
    }
}
Home | Imprint | This part of the site doesn't use cookies.