Skip to content

Commit 18e6288

Browse files
Merge pull request #29533 from nextcloud/enhancement/get-calendars-for-principal-api
Add IManager::getCalendarsForPrincipal API
2 parents b453fea + 3ef6a09 commit 18e6288

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

lib/private/Calendar/Manager.php

+12-5
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,14 @@ private function loadCalendars() {
167167
$this->calendarLoaders = [];
168168
}
169169

170-
public function searchForPrincipal(ICalendarQuery $query): array {
170+
public function getCalendarsForPrincipal(string $principalUri, array $calendarUris = []): array {
171171
$context = $this->coordinator->getRegistrationContext();
172172
if ($context === null) {
173173
return [];
174174
}
175175

176-
/** @var CalendarQuery $query */
177-
$calendars = array_merge(
178-
...array_map(function ($registration) use ($query) {
176+
return array_merge(
177+
...array_map(function ($registration) use ($principalUri, $calendarUris) {
179178
try {
180179
/** @var ICalendarProvider $provider */
181180
$provider = $this->container->get($registration->getService());
@@ -186,9 +185,17 @@ public function searchForPrincipal(ICalendarQuery $query): array {
186185
return [];
187186
}
188187

189-
return $provider->getCalendars($query->getPrincipalUri(), $query->getCalendarUris());
188+
return $provider->getCalendars($principalUri, $calendarUris);
190189
}, $context->getCalendarProviders())
191190
);
191+
}
192+
193+
public function searchForPrincipal(ICalendarQuery $query): array {
194+
/** @var CalendarQuery $query */
195+
$calendars = $this->getCalendarsForPrincipal(
196+
$query->getPrincipalUri(),
197+
$query->getCalendarUris(),
198+
);
192199

193200
$results = [];
194201
/** @var ICalendar $calendar */

lib/public/Calendar/ICalendarProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
interface ICalendarProvider {
3737

3838
/**
39-
* @param string $principalUri
40-
* @param string[] $calendarUris
39+
* @param string $principalUri URI of the principal
40+
* @param string[] $calendarUris optionally specify which calendars to load, or all if this array is empty
4141
* @return ICalendar[]
4242
* @since 23.0.0
4343
*/

lib/public/Calendar/IManager.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function register(\Closure $callable);
118118
/**
119119
* @return ICalendar[]
120120
* @since 13.0.0
121-
* @deprecated 23.0.0
121+
* @deprecated 23.0.0 use \OCP\Calendar\IManager::getCalendarsForPrincipal
122122
*/
123123
public function getCalendars();
124124

@@ -131,6 +131,15 @@ public function getCalendars();
131131
*/
132132
public function clear();
133133

134+
/**
135+
* @param string $principalUri URI of the principal
136+
* @param string[] $calendarUris optionally specify which calendars to load, or all if this array is empty
137+
*
138+
* @return ICalendar[]
139+
* @since 23.0.0
140+
*/
141+
public function getCalendarsForPrincipal(string $principalUri, array $calendarUris = []): array;
142+
134143
/**
135144
* Query a principals calendar(s)
136145
*

0 commit comments

Comments
 (0)