From bdc3b32f3490222f1fa258ac138b540aae5f350b Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 2 Mar 2020 00:29:08 +0300 Subject: [PATCH] feat(admin-plugin): do not rewrite plugins and themes manifest with custom manifests. --- flextype/core/Plugins.php | 21 +++------------------ flextype/core/Themes.php | 19 ++----------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/flextype/core/Plugins.php b/flextype/core/Plugins.php index 93c6671a..012e9107 100755 --- a/flextype/core/Plugins.php +++ b/flextype/core/Plugins.php @@ -102,7 +102,6 @@ class Plugins $default_plugin_settings = []; $site_plugin_settings = []; $default_plugin_manifest = []; - $site_plugin_manifest = []; // Go through... foreach ($plugins_list as $plugin) { @@ -114,9 +113,8 @@ class Plugins $default_plugin_settings_file = PATH['plugins'] . '/' . $plugin['dirname'] . '/settings.yaml'; $default_plugin_manifest_file = PATH['plugins'] . '/' . $plugin['dirname'] . '/plugin.yaml'; - // Set site plugin settings and manifest files + // Set site plugin settings file $site_plugin_settings_file = PATH['config']['site'] . '/plugins/' . $plugin['dirname'] . '/settings.yaml'; - $site_plugin_manifest_file = PATH['config']['site'] . '/plugins/' . $plugin['dirname'] . '/plugin.yaml'; // Create site plugin settings directory ! Filesystem::has($site_plugin_settings_dir) and Filesystem::createDir($site_plugin_settings_dir); @@ -150,21 +148,10 @@ class Plugins $default_plugin_manifest_file_content = Filesystem::read($default_plugin_manifest_file); $default_plugin_manifest = $this->flextype['parser']->decode($default_plugin_manifest_file_content, 'yaml'); - // Create site plugin manifest file - ! Filesystem::has($site_plugin_manifest_file) and Filesystem::write($site_plugin_manifest_file, $default_plugin_manifest_file_content); - - // Get site plugin manifest content - $site_plugin_manifest_file_content = Filesystem::read($site_plugin_manifest_file); - if (trim($site_plugin_manifest_file_content) === '') { - $site_plugin_manifest = []; - } else { - $site_plugin_manifest = $this->flextype['parser']->decode($site_plugin_manifest_file_content, 'yaml'); - } - // Merge plugin settings and manifest data $plugins[$plugin['dirname']] = array_merge( array_replace_recursive($default_plugin_settings, $site_plugin_settings), - array_replace_recursive($default_plugin_manifest, $site_plugin_manifest) + $default_plugin_manifest ); // Check if isset plugin priority @@ -237,14 +224,12 @@ class Plugins $default_plugin_settings_file = PATH['plugins'] . '/' . $plugin['dirname'] . '/settings.yaml'; $default_plugin_manifest_file = PATH['plugins'] . '/' . $plugin['dirname'] . '/plugin.yaml'; $site_plugin_settings_file = PATH['config']['site'] . '/plugins/' . $plugin['dirname'] . '/settings.yaml'; - $site_plugin_manifest_file = PATH['config']['site'] . '/plugins/' . $plugin['dirname'] . '/plugin.yaml'; $f1 = Filesystem::has($default_plugin_settings_file) ? filemtime($default_plugin_settings_file) : ''; $f2 = Filesystem::has($default_plugin_manifest_file) ? filemtime($default_plugin_manifest_file) : ''; $f3 = Filesystem::has($site_plugin_settings_file) ? filemtime($site_plugin_settings_file) : ''; - $f4 = Filesystem::has($site_plugin_manifest_file) ? filemtime($site_plugin_manifest_file) : ''; - $_plugins_cache_id .= $f1 . $f2 . $f3 . $f4; + $_plugins_cache_id .= $f1 . $f2 . $f3; } } diff --git a/flextype/core/Themes.php b/flextype/core/Themes.php index cbca4e1d..57c78adc 100644 --- a/flextype/core/Themes.php +++ b/flextype/core/Themes.php @@ -64,7 +64,6 @@ class Themes $default_theme_settings = []; $site_theme_settings = []; $default_theme_manifest = []; - $site_theme_manifest = []; // Go through the themes list... foreach ($themes_list as $theme) { @@ -78,7 +77,6 @@ class Themes // Set custom theme settings and manifest files $custom_theme_settings_file = PATH['config']['site'] . '/themes/' . $theme['dirname'] . '/settings.yaml'; - $custom_theme_manifest_file = PATH['config']['site'] . '/themes/' . $theme['dirname'] . '/theme.yaml'; // Create custom theme settings directory ! Filesystem::has($custom_theme_settings_dir) and Filesystem::createDir($custom_theme_settings_dir); @@ -116,21 +114,10 @@ class Themes $default_theme_manifest_file_content = Filesystem::read($default_theme_manifest_file); $default_theme_manifest = $this->flextype['parser']->decode($default_theme_manifest_file_content, 'yaml'); - // Create custom theme file - ! Filesystem::has($custom_theme_manifest_file) and Filesystem::write($custom_theme_manifest_file, $default_theme_manifest_file_content); - - // Get custom theme manifest content - $custom_theme_manifest_file_content = Filesystem::read($custom_theme_manifest_file); - if (trim($custom_theme_manifest_file_content) === '') { - $custom_theme_manifest = []; - } else { - $custom_theme_manifest = $this->flextype['parser']->decode($custom_theme_manifest_file_content, 'yaml'); - } - // Merge theme settings and manifest data $themes[$theme['dirname']] = array_merge( array_replace_recursive($default_theme_settings, $custom_theme_settings), - array_replace_recursive($default_theme_manifest, $custom_theme_manifest) + $default_theme_manifest ); } @@ -163,14 +150,12 @@ class Themes $default_theme_settings_file = PATH['themes'] . '/' . $theme['dirname'] . '/settings.yaml'; $default_theme_manifest_file = PATH['themes'] . '/' . $theme['dirname'] . '/theme.yaml'; $site_theme_settings_file = PATH['config']['site'] . '/themes/' . $theme['dirname'] . '/settings.yaml'; - $site_theme_manifest_file = PATH['config']['site'] . '/themes/' . $theme['dirname'] . '/theme.yaml'; $f1 = Filesystem::has($default_theme_settings_file) ? filemtime($default_theme_settings_file) : ''; $f2 = Filesystem::has($default_theme_manifest_file) ? filemtime($default_theme_manifest_file) : ''; $f3 = Filesystem::has($site_theme_settings_file) ? filemtime($site_theme_settings_file) : ''; - $f4 = Filesystem::has($site_theme_manifest_file) ? filemtime($site_theme_manifest_file) : ''; - $_themes_cache_id .= $f1 . $f2 . $f3 . $f4; + $_themes_cache_id .= $f1 . $f2 . $f3; } }