MCPcopy Create free account
hub / github.com/Rello/analytics / ContentProvider

Class ContentProvider

lib/ContextChat/ContentProvider.php:24–82  ·  view source on GitHub ↗

* This interface defines methods to implement a content provider * @since 1.1.0 */

Source from the content-addressed store, hash-verified

22 * @since 1.1.0
23 */
24class ContentProvider implements IContentProvider, IEventListener {
25 private $logger;
26
27 public function __construct(
28 private IURLGenerator $urlGenerator,
29 private IJobList $jobList,
30 LoggerInterface $logger,
31 ) {
32 $this->logger = $logger;
33 }
34
35 public function handle(Event $event): void {
36 if (!$event instanceof ContentProviderRegisterEvent) {
37 return;
38 }
39 $event->registerContentProvider('analytics', 'report', ContentProvider::class);
40 }
41
42 /**
43 * The ID of the provider
44 *
45 * @return string
46 * @since 1.1.0
47 */
48 public function getId(): string {
49 return 'report';
50 }
51
52 /**
53 * The ID of the app making the provider avaialble
54 *
55 * @return string
56 * @since 1.1.0
57 */
58 public function getAppId(): string {
59 return 'analytics';
60 }
61
62 /**
63 * The absolute URL to the content item
64 *
65 * @param string $id
66 * @return string
67 * @since 1.1.0
68 */
69 public function getItemUrl(string $id): string {
70 return $this->urlGenerator->linkToRouteAbsolute('analytics.page.main') . 'r/' . $id;
71 }
72
73 /**
74 * Starts the initial import of content items into content chat
75 *
76 * @return void
77 * @since 1.1.0
78 */
79 public function triggerInitialImport(): void {
80 $this->jobList->add(ContextChatInitialImport::class);
81 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected