* @license PHP License * @package WB * @subpackage Tag */ WBClass::load('WBDatasource_Calendar_Holiday'); /** * Public Holiday Importer De * * Download from API server and store in database * * @version 0.1.0 * @package WB * @subpackage db */ class WBDatasource_Calendar_Holiday_Importer_De extends WBDatasource_Calendar_Holiday_Importer { /** * Second Constructor */ protected function init() { } /** * Update Holiday List 4 Year * * @param int */ protected function updateYear($year) { $url = 'https://feiertage-api.de/api/?jahr=%d'; $url = sprintf($url, $year); $cnt = file_get_contents($url); $list = json_decode($cnt, true); $this->saveList4Region('', $list['NATIONAL']); foreach ($list as $r => $reg) { if ('NATIONAL' == $r) { continue; } $this->saveList4Region($r, $reg); } } private function saveList4Region($region, $list) { $this->holiday->useCountry('de', $region); foreach ($list as $t => $l) { $data = array( 'title' => $t, 'holiday' => $l['datum'], 'brief' => $l['hinweis'], 'country' => 'de', 'region' => $region ); $id = $this->holiday->save($data); } } }