migration banner logic

Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
Andy Miller
2026-04-16 18:24:06 +01:00
parent 30a90cc69b
commit 38efb7d892
4 changed files with 169 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ use Grav\Common\Cache;
use Grav\Common\Data\Data;
use Grav\Common\Debugger;
use Grav\Common\File\CompiledYamlFile;
use Grav\Common\GPM\Upgrader;
use Grav\Common\Grav;
use Grav\Common\Helpers\LogViewer;
use Grav\Common\Inflector;
@@ -743,6 +744,21 @@ class AdminPlugin extends Plugin
switch ($this->template) {
case 'dashboard':
$twig->twig_vars['popularity'] = $this->popularity;
// Cross-family migration notice: when the remote advertises a new major,
// surface a one-time banner on the dashboard. Uses cached GPM data; failures
// must not break the dashboard.
try {
$upgrader = new Upgrader();
if (method_exists($upgrader, 'isNextMajorAvailable') && $upgrader->isNextMajorAvailable()) {
$twig->twig_vars['grav_next_major'] = [
'version' => $upgrader->getNextMajorVersion(),
'migration_url' => $upgrader->getMigrationUrl(),
];
}
} catch (\Throwable $e) {
// Swallow — notice is informational only.
}
break;
}