-
-
Notifications
You must be signed in to change notification settings - Fork 31
Register own datasource
Rello edited this page Jul 4, 2024
·
6 revisions
External applications can register their own datasource via an event listener.
The app must register DatasourceEvent
and implement IDatasource
to deliver the data.
use OCA\Analytics\Datasource\DatasourceEvent;
use OCA\xxx\Listener\AnalyticsDatasourceListener;
...
public function register(IRegistrationContext $context): void
{
$context->registerEventListener(DatasourceEvent::class, AnalyticsDatasourceListener::class);
}
<?php
declare(strict_types=1);
namespace OCA\xxx\Listener;
use OCA\xxx\Analytics\Datasource;
use OCA\Analytics\Datasource\DatasourceEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
class AnalyticsDatasourceListener implements IEventListener {
public function handle(Event $event): void {
if (!($event instanceof DatasourceEvent)) {
// Unrelated
return;
}
$event->registerDatasource(Datasource::class);
}
}
must implement IDatasource;