| 1 |
<?php |
| 2 |
namespace Timetics\Core\Staffs\Calendars; |
| 3 |
|
| 4 |
class CalendarSyncFactory { |
| 5 |
/** |
| 6 |
* Get calendar services |
| 7 |
* |
| 8 |
* @param string $teamMemberId Integer |
| 9 |
* |
| 10 |
* @return array Calendar services list |
| 11 |
*/ |
| 12 |
public static function getSyncServices(string $teamMemberId): array { |
| 13 |
// Fetch all calendars configured for this team member |
| 14 |
$calendars = timetics_connected_platforms( $teamMemberId ); |
| 15 |
|
| 16 |
$services = []; |
| 17 |
|
| 18 |
foreach ( $calendars as $calendar ) { |
| 19 |
switch ( $calendar ) { |
| 20 |
case 'google-calendar': |
| 21 |
$services[] = new GoogleCalendarSync(); |
| 22 |
break; |
| 23 |
|
| 24 |
default: |
| 25 |
// Do nothing for unsupported platforms |
| 26 |
break; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
return array_filter( $services ); // Remove any `null` values |
| 31 |
} |
| 32 |
} |
| 33 |
|