2025-09-09 12:07:53 +02:00
|
|
|
<?php
|
|
|
|
|
|
2025-09-16 12:05:35 +02:00
|
|
|
namespace davina\sources;
|
2025-09-09 12:07:53 +02:00
|
|
|
|
2025-09-16 12:48:45 +02:00
|
|
|
require_once(DIR_LOGIC . '/sources/ics_feed.php');
|
2025-09-09 12:07:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $descriptor {
|
|
|
|
|
* record<
|
|
|
|
|
* kind:string,
|
|
|
|
|
* data:any
|
|
|
|
|
* >
|
|
|
|
|
* }
|
|
|
|
|
*/
|
|
|
|
|
function make(
|
|
|
|
|
array $descriptor
|
|
|
|
|
) : interface_source
|
|
|
|
|
{
|
|
|
|
|
switch ($descriptor['kind'])
|
|
|
|
|
{
|
|
|
|
|
case 'ics_feed':
|
|
|
|
|
{
|
2025-09-09 23:17:19 +02:00
|
|
|
return (
|
|
|
|
|
new class_source_ics_feed(
|
|
|
|
|
$descriptor['data']['url'],
|
|
|
|
|
($descriptor['data']['lifetime'] ?? (60 * 15)),
|
|
|
|
|
($descriptor['data']['combine'] ?? false)
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-09-09 12:07:53 +02:00
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
2025-09-09 23:17:19 +02:00
|
|
|
throw (
|
|
|
|
|
new \Exception(
|
|
|
|
|
\sprintf(
|
|
|
|
|
'unhandled source kind: %s',
|
|
|
|
|
$descriptor['kind']
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
2025-09-09 12:07:53 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|