mirror of
https://github.com/nextcloud/documentation.git
synced 2026-01-03 18:26:42 +07:00
Add dev docs for the calendar providers API in Nextcloud 23
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
@@ -4,6 +4,39 @@ Calendar integration
|
||||
|
||||
On this page you can learn more about integrating with the Nextcloud calendar services.
|
||||
|
||||
Calendar providers
|
||||
------------------
|
||||
|
||||
Nextcloud apps can register calendars in addition to the internal calendars of the Nextcloud CalDAV back end. Calendars are only loaded on demand, therefore a lazy provider mechanism is used.
|
||||
|
||||
To provide calendar(s) you have to write a class that implements the ``ICalendarProvider`` interface.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
|
||||
use OCP\Calendar\ICalendarProvider;
|
||||
|
||||
class CalendarProvider implements ICalendarProvider {
|
||||
|
||||
public function getCalendars(string $principalUri, array $calendarUris = []): array {
|
||||
$calendars = [];
|
||||
// TODO: Run app specific logic to find calendars that belong to
|
||||
// $principalUri and fill $calendars
|
||||
|
||||
// The provider can simple return an empty array if there is not
|
||||
// a single calendar for the principal URI
|
||||
if (empty($calendars)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Return instances of \OCP\Calendar\ICalendar
|
||||
return $calendars;
|
||||
}
|
||||
}
|
||||
|
||||
This ``CalendarProvider`` class is then registered in the :ref:`register method of your Application class<Bootstrapping>` with ``$context->registerCalendarProvider(CalendarProvider::class);``.
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user