-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
39 lines (31 loc) · 1.18 KB
/
index.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
38
39
<?php
@include_once __DIR__ . '/vendor/autoload.php';
Kirby::plugin('hashsandsalt/yasumi', [
'siteMethods' => [
'holidays' => function ($country, $year, $locale = 'en_US') {
$holidays = Yasumi\Yasumi::create($country, $year, $locale);
return $holidays;
}
],
'collections' => [
'holidays' => function ($site) {
$country = option('hashandsalt.yasumi.country', 'UnitedKingdom');
$year = option('hashandsalt.yasumi.year', date('Y'));
$locale = option('hashandsalt.yasumi.locale', 'en_GB');
foreach ($site->holidays($country, $year, $locale) as $holiday) {
$date = new DateTime($holiday);
$pages[] = [
'slug' => $holiday->shortName,
'num' => $date->format('Ymd'),
'template' => 'yasumi',
'content' => [
'title' => $holiday->getName(),
'date' => $date->format('Y-m-d'),
'type' => $holiday->getType()
]
];
}
return Pages::factory($pages);
}
]
]);