updater->version(...)), new TwigFunction('kant_update_version', $this->available(...)), new TwigFunction('kant_admin_notices', $this->notices(...)), ]; } /** * Was auf jedem Verwaltungsbildschirm oben stehen soll, weil es einen Knopf braucht. * * Keine Zeile davon geht ins Netz: die verfügbare Fassung steht im Protokoll der täglichen * Aufgabe, die fehlenden Schriften stehen als Dateien im Ordner. Ein Hinweis, der bei jedem * Klick eine fremde Verbindung öffnet, wäre die Sorte Hinweis, die man abschaltet. * * @return list */ public function notices(): array { $notices = []; if (null !== $version = $this->available()) { $notices[] = [ 'kind' => 'update', 'text' => sprintf('Fassung %s ist verfügbar; installiert ist %s.', $version, $this->updater->version()), 'route' => 'admin_system', 'action' => 'Jetzt aktualisieren', 'admin' => true, ]; } try { $missing = $this->fonts->missing($this->theme->load()); } catch (\Throwable) { // Eine Installation, die noch auf ihre Migrationen wartet, hat noch kein Theme. $missing = []; } if ([] !== $missing) { $notices[] = [ 'kind' => 'fonts', 'text' => sprintf('Schriftdateien fehlen auf diesem Server: %s. Bis dahin zeigt die Website die Ersatzschrift.', implode(', ', $missing)), 'route' => 'admin_theme', 'action' => 'Schriften holen', 'admin' => false, ]; } return $notices; } public function available(): ?string { // The daily worker already checks releases. Rendering navigation never contacts Git. try { $message = $this->db->fetchOne('SELECT last_message FROM scheduled_task WHERE name = ?', ['update-check']); if (is_string($message) && 1 === preg_match('/^Fassung (\d+\.\d+\.\d+) ist verfügbar/', $message, $match) && version_compare($match[1], $this->updater->version(), '>')) { return $match[1]; } } catch (\Doctrine\DBAL\Exception) { // An installation still waiting for migrations has no task table yet. } return null; } }