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

feat(admin-plugin): do not rewrite plugins and themes manifest with custom manifests.

This commit is contained in:
Awilum
2020-03-02 00:29:08 +03:00
parent 26e3bba010
commit bdc3b32f34
2 changed files with 5 additions and 35 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}