mirror of
https://github.com/flextype/flextype.git
synced 2025-08-17 18:36:39 +02:00
Flextype fallback settings implementation
This commit is contained in:
@@ -138,15 +138,29 @@ class Flextype
|
||||
*/
|
||||
private static function setConfig() : void
|
||||
{
|
||||
// Set empty site item
|
||||
// Set empty site settings array
|
||||
Registry::set('settings', []);
|
||||
|
||||
// Set settings items if settings config exists
|
||||
if (Filesystem::fileExists($settings_config = PATH['config'] . '/' . 'settings.yaml')) {
|
||||
Registry::set('settings', Yaml::parseFile($settings_config));
|
||||
// Set settings files path
|
||||
$default_settings_file_path = PATH['config']['default'] . '/settings.yaml';
|
||||
$site_settings_file_path = PATH['config']['site'] . '/settings.yaml';
|
||||
|
||||
// Set settings if Flextype settings and Site settings config files exist
|
||||
if (Filesystem::fileExists($default_settings_file_path) && Filesystem::fileExists($site_settings_file_path)) {
|
||||
|
||||
// Get Flextype settings and Site settings
|
||||
$default_settings = Yaml::parseFile($default_settings_file_path);
|
||||
$site_settings = Yaml::parseFile($site_settings_file_path);
|
||||
|
||||
// Merge settings
|
||||
$settings = array_merge($default_settings, $site_settings);
|
||||
|
||||
// Set settings
|
||||
Registry::set('settings', $settings);
|
||||
} else {
|
||||
throw new \RuntimeException("Flextype settings config file does not exist.");
|
||||
throw new \RuntimeException("Flextype settings and Site settings config files does not exist.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
21
flextype/config/settings.yaml
Normal file
21
flextype/config/settings.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
title: Flextype
|
||||
description: 'Modern Open Source Flat-File Content Management System'
|
||||
keywords: 'flextype, php, cms, flat-file cms, flat cms, flatfile cms, html'
|
||||
robots: 'index, follow'
|
||||
author:
|
||||
name: ''
|
||||
email: ''
|
||||
timezone: UTC
|
||||
date_format: 'F d Y H:i:s'
|
||||
charset: UTF-8
|
||||
theme: nes
|
||||
locale: en
|
||||
pages:
|
||||
main: home
|
||||
errors:
|
||||
display: true
|
||||
cache:
|
||||
enabled: true
|
||||
prefix: flextype
|
||||
driver: auto
|
||||
lifetime: 604800
|
Reference in New Issue
Block a user