-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreefinder.php
37 lines (28 loc) · 969 Bytes
/
freefinder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require(__DIR__.'/vendor/autoload.php');
$config_file = __DIR__.'/settings.json';
$providers = [];
$events = [];
// Load configuration file
if (!file_exists($config_file)) {
throw new Exception("The file '$config_file' does not exist!");
}
$settings = json_decode(file_get_contents($config_file));
if (!$settings) {
throw new Exception("Was not able to load configuration file '$config_file'.");
}
// Read settings and create providers
foreach ($settings->providers as $provider_settings) {
if (!class_exists($provider_settings->name)) {
throw new Exception("The provider '{$provider_settings->name}' is not implented!");
}
$providers[] = new $provider_settings->name($provider_settings->settings);
}
// Load events
foreach ($providers as $provider) {
$events = array_merge($events, $provider->getEvents());
}
// Show event titles
foreach ($events as $event) {
printf("Event '%s'".PHP_EOL, $event->VEVENT->SUMMARY);
}