You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
798 B
PHP
32 lines
798 B
PHP
#!/usr/bin/env php
|
|
<?php
|
|
|
|
require_once __DIR__ . '/../includes/application.php';
|
|
|
|
require_once __DIR__ . '/../includes/pages/schedule/ImportSchedule.php';
|
|
use Engelsystem\Controllers\Admin\Schedule\ImportSchedule;
|
|
|
|
$script = array_shift($argv);
|
|
if (count($argv) === 0) {
|
|
echo "usage: $script '*'|SCHEDULE_ID [SCHEDULE_ID...]" . PHP_EOL;
|
|
exit;
|
|
}
|
|
|
|
$app = app();
|
|
|
|
$scheduleIds = $argv;
|
|
if ($argv[0] === '*') {
|
|
$db = $app->get('db');
|
|
$scheduleIds = array_map(fn(stdClass $schedule) => $schedule->id, $db->select('SELECT id FROM schedules'));
|
|
}
|
|
|
|
$importer = $app->get(ImportSchedule::class);
|
|
|
|
foreach ($scheduleIds as $id) {
|
|
try {
|
|
$importer->doImport($id);
|
|
} catch (ErrorException $e) {
|
|
echo "import '$id' failed:" . PHP_EOL . $e->getMessage() . PHP_EOL;
|
|
}
|
|
}
|