1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-15 17:44:17 +02:00

Custom YamlParser with native support - implementation

This commit is contained in:
Awilum
2018-12-17 22:15:52 +03:00
parent 81e31d1324
commit 0b3d49451a
3 changed files with 6 additions and 9 deletions

View File

@@ -17,7 +17,6 @@ use Flextype\Component\Http\Http;
use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Event\Event;
use Flextype\Component\Registry\Registry;
use Symfony\Component\Yaml\Yaml;
use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
@@ -365,7 +364,7 @@ class Content
$_page = [];
// Process $page_frontmatter with YAML and Shortcodes parsers
$_page = Yaml::parse(Content::processShortcodes($page_frontmatter));
$_page = YamlParser::decode(Content::processShortcodes($page_frontmatter));
// Create page url item
$url = str_replace(PATH['pages'], Http::getBaseUrl(), $file_path);

View File

@@ -16,7 +16,6 @@ use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\Event\Event;
use Flextype\Component\I18n\I18n;
use Flextype\Component\Registry\Registry;
use Symfony\Component\Yaml\Yaml;
class Plugins
{
@@ -290,11 +289,11 @@ class Plugins
// Go through...
foreach ($plugins_list as $plugin) {
if (Filesystem::fileExists($_plugin_settings = PATH['plugins'] . '/' . $plugin . '/settings.yaml')) {
$plugin_settings = Yaml::parseFile($_plugin_settings);
$plugin_settings = YamlParser::decode(Filesystem::getFileContent($_plugin_settings));
}
if (Filesystem::fileExists($_plugin_config = PATH['plugins'] . '/' . $plugin . '/'. $plugin. '.yaml')) {
$plugin_config = Yaml::parseFile($_plugin_config);
$plugin_config = YamlParser::decode(Filesystem::getFileContent($_plugin_config));
}
$_plugins_config[basename($_plugin_config, '.yaml')] = array_merge($plugin_settings, $plugin_config);
@@ -311,7 +310,7 @@ class Plugins
foreach ($plugins_list as $plugin) {
$language_file = PATH['plugins'] . '/' . $plugin . '/languages/' . $locale . '.yaml';
if (Filesystem::fileExists($language_file)) {
I18n::add(Yaml::parseFile($language_file), $locale);
I18n::add(YamlParser::decode(Filesystem::getFileContent($language_file)), $locale);
}
}
}

View File

@@ -15,7 +15,6 @@ namespace Flextype;
use Flextype\Component\Filesystem\Filesystem;
use Flextype\Component\View\View;
use Flextype\Component\Registry\Registry;
use Symfony\Component\Yaml\Yaml;
class Themes
{
@@ -84,8 +83,8 @@ class Themes
} else {
if (Filesystem::fileExists($theme_settings = PATH['themes'] . '/' . $theme . '/' . 'settings.yaml') and
Filesystem::fileExists($theme_config = PATH['themes'] . '/' . $theme . '/' . $theme . '.yaml')) {
$theme_settings = Yaml::parseFile($theme_settings);
$theme_config = Yaml::parseFile($theme_config);
$theme_settings = YamlParser::decode(Filesystem::getFileContent($theme_settings));
$theme_config = YamlParser::decode(Filesystem::getFileContent($theme_config));
$_theme = array_merge($theme_settings, $theme_config);
Registry::set('themes.'.Registry::get('settings.theme'), $_theme);
Cache::save($theme_cache_id, $_theme);