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