Merge pull request #29533 from nextcloud/enhancement/get-calendars-for-principal-api

Add IManager::getCalendarsForPrincipal API
pull/29546/head
Christoph Wurst 2021-11-04 07:33:49 +07:00 committed by GitHub
commit 18e6288c89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 8 deletions

@ -167,15 +167,14 @@ class Manager implements IManager {
$this->calendarLoaders = [];
}
public function searchForPrincipal(ICalendarQuery $query): array {
public function getCalendarsForPrincipal(string $principalUri, array $calendarUris = []): array {
$context = $this->coordinator->getRegistrationContext();
if ($context === null) {
return [];
}
/** @var CalendarQuery $query */
$calendars = array_merge(
...array_map(function ($registration) use ($query) {
return array_merge(
...array_map(function ($registration) use ($principalUri, $calendarUris) {
try {
/** @var ICalendarProvider $provider */
$provider = $this->container->get($registration->getService());
@ -186,9 +185,17 @@ class Manager implements IManager {
return [];
}
return $provider->getCalendars($query->getPrincipalUri(), $query->getCalendarUris());
return $provider->getCalendars($principalUri, $calendarUris);
}, $context->getCalendarProviders())
);
}
public function searchForPrincipal(ICalendarQuery $query): array {
/** @var CalendarQuery $query */
$calendars = $this->getCalendarsForPrincipal(
$query->getPrincipalUri(),
$query->getCalendarUris(),
);
$results = [];
/** @var ICalendar $calendar */

@ -36,8 +36,8 @@ namespace OCP\Calendar;
interface ICalendarProvider {
/**
* @param string $principalUri
* @param string[] $calendarUris
* @param string $principalUri URI of the principal
* @param string[] $calendarUris optionally specify which calendars to load, or all if this array is empty
* @return ICalendar[]
* @since 23.0.0
*/

@ -118,7 +118,7 @@ interface IManager {
/**
* @return ICalendar[]
* @since 13.0.0
* @deprecated 23.0.0
* @deprecated 23.0.0 use \OCP\Calendar\IManager::getCalendarsForPrincipal
*/
public function getCalendars();
@ -131,6 +131,15 @@ interface IManager {
*/
public function clear();
/**
* @param string $principalUri URI of the principal
* @param string[] $calendarUris optionally specify which calendars to load, or all if this array is empty
*
* @return ICalendar[]
* @since 23.0.0
*/
public function getCalendarsForPrincipal(string $principalUri, array $calendarUris = []): array;
/**
* Query a principals calendar(s)
*