From cced8b01caa043cf658f9a632c90c1242bcc46a5 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 1 Nov 2020 21:28:54 +0300 Subject: [PATCH] feat(preflight): use Atomastic Filesystem #478 --- src/flextype/preflight.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/flextype/preflight.php b/src/flextype/preflight.php index c8b39a17..f395dc82 100644 --- a/src/flextype/preflight.php +++ b/src/flextype/preflight.php @@ -10,8 +10,8 @@ $custom_flextype_settings_file_path = PATH['project'] . '/config/flextype/setti $preflight_flextype_path = PATH['tmp'] . '/preflight/flextype/'; $custom_flextype_settings_path = PATH['project'] . '/config/flextype/'; -! filesystem()->file($preflight_flextype_path)->exists() and filesystem()->directory($preflight_flextype_path)->create(0755, true); -! filesystem()->file($custom_flextype_settings_path)->exists() and filesystem()->directory($custom_flextype_settings_path)->create(0755, true); +! filesystem()->directory($preflight_flextype_path)->exists() and filesystem()->directory($preflight_flextype_path)->create(0755, true); +! filesystem()->directory($custom_flextype_settings_path)->exists() and filesystem()->directory($custom_flextype_settings_path)->create(0755, true); $f1 = file_exists($flextype_manifest_file_path) ? filemtime($flextype_manifest_file_path) : ''; $f2 = file_exists($default_flextype_settings_file_path) ? filemtime($default_flextype_settings_file_path) : ''; @@ -20,12 +20,9 @@ $f3 = file_exists($custom_flextype_settings_file_path) ? filemtime($custom_flext // Create Unique Cache ID $cache_id = md5($flextype_manifest_file_path . $default_flextype_settings_file_path . $custom_flextype_settings_file_path . $f1 . $f2 . $f3); -if (filesystem()->file($preflight_flextype_path . '/' . $cache_id . '.php')->exists()) { - $flextype_data = require $preflight_flextype_path . '/' . $cache_id . '.php'; +if (filesystem()->file($preflight_flextype_path . '/' . $cache_id . '.txt')->exists()) { + $flextype_data = unserialize(filesystem()->file($preflight_flextype_path . '/' . $cache_id . '.txt')->get()); } else { - // Drop the flextype preflight dir and create new one. - filesystem()->directory($preflight_flextype_path)->delete(); - // Set settings if Flextype Default settings config files exist if (! filesystem()->file($default_flextype_settings_file_path)->exists()) { throw new RuntimeException('Flextype Default settings config file does not exist.'); @@ -67,7 +64,7 @@ if (filesystem()->file($preflight_flextype_path . '/' . $cache_id . '.php')->exi // Merge flextype default settings with custom project settings. $flextype_data = array_replace_recursive($default_flextype_settings, $custom_flextype_settings, $flextype_manifest); - //@todo remove this: filesystem()->file($preflight_flextype_path . $cache_id . '.php')->put(sprintf('file($preflight_flextype_path . $cache_id . '.txt')->put(serialize($flextype_data)); } // Store flextype merged data in the flextype registry.