forked from laysense/laysite
Prepare LaySite 1.5.1 page routing and template updates
This commit is contained in:
@@ -63,16 +63,20 @@ final class SiteDesign
|
||||
});
|
||||
}
|
||||
|
||||
public static function unsetSystemPage(PDO $pdo, string $slug): void
|
||||
public static function replaceSystemPage(PDO $pdo, string $slug, ?string $replacement = null): void
|
||||
{
|
||||
$site = json_decode((string) $pdo->query('SELECT payload FROM site_settings WHERE id = 1')->fetchColumn(), true, flags: JSON_THROW_ON_ERROR);
|
||||
$type = array_search($slug, $site['system_pages'] ?? [], true);
|
||||
if ($type === false) {
|
||||
return;
|
||||
}
|
||||
unset($site['system_pages'][$type]);
|
||||
if ($type === 'maintenance') {
|
||||
$site['maintenance_enabled'] = false;
|
||||
if ($replacement !== null) {
|
||||
$site['system_pages'][$type] = $replacement;
|
||||
} else {
|
||||
unset($site['system_pages'][$type]);
|
||||
if ($type === 'maintenance') {
|
||||
$site['maintenance_enabled'] = false;
|
||||
}
|
||||
}
|
||||
$site['revisions']['general'] = ($site['revisions']['general'] ?? 0) + 1;
|
||||
$pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);
|
||||
|
||||
Reference in New Issue
Block a user