diff --git a/flextype/Cache.php b/flextype/Cache.php index 0adfd87e..5cfca649 100755 --- a/flextype/Cache.php +++ b/flextype/Cache.php @@ -12,6 +12,7 @@ namespace Flextype; +use Flextype\Component\Filesystem\Filesystem; use \Doctrine\Common\Cache as DoctrineCache; class Cache @@ -165,7 +166,7 @@ class Cache break; default: // Create doctrine cache directory if its not exists - !Flextype::filesystem()->exists($cache_directory = CACHE_PATH . '/doctrine/') and Flextype::filesystem()->mkdir($cache_directory); + !Filesystem::fileExists($cache_directory = CACHE_PATH . '/doctrine/') and Filesystem::createDir($cache_directory); $driver = new DoctrineCache\FilesystemCache($cache_directory); break; } @@ -242,7 +243,7 @@ class Cache function_exists('opcache_reset') and @opcache_reset(); // Remove cache dir - Flextype::filesystem()->remove(CACHE_PATH . '/doctrine/'); + Filesystem::deleteDir(CACHE_PATH . '/doctrine/'); } /** diff --git a/flextype/Config.php b/flextype/Config.php index 52c3f557..b93a9b0b 100755 --- a/flextype/Config.php +++ b/flextype/Config.php @@ -12,7 +12,7 @@ namespace Flextype; -use Flextype\Component\Arr\Arr; +use Flextype\Component\{Arr\Arr, Filesystem\Filesystem}; use Symfony\Component\Yaml\Yaml; class Config @@ -62,8 +62,8 @@ class Config */ protected static function init() : void { - if (Flextype::filesystem()->exists($site_config = CONFIG_PATH . '/' . 'site.yml')) { - static::$config['site'] = Yaml::parse(file_get_contents($site_config)); + if (Filesystem::fileExists($site_config = CONFIG_PATH . '/' . 'site.yml')) { + static::$config['site'] = Yaml::parseFile($site_config); } else { throw new RuntimeException("Flextype site config file does not exist."); } diff --git a/flextype/I18n.php b/flextype/I18n.php index a7070b96..5a056090 100644 --- a/flextype/I18n.php +++ b/flextype/I18n.php @@ -12,6 +12,7 @@ namespace Flextype; +use Flextype\Component\Filesystem\Filesystem; use Symfony\Component\Yaml\Yaml; class I18n @@ -108,8 +109,8 @@ class I18n foreach (static::$locales as $locale => $locale_title) { foreach ($plugins_list as $plugin) { $language_file = PLUGINS_PATH . '/' . $plugin . '/languages/' . $locale . '.yml'; - if (file_exists($language_file)) { - $dictionary[$plugin][$locale] = Yaml::parse(file_get_contents($language_file)); + if (Filesystem::fileExists($language_file)) { + $dictionary[$plugin][$locale] = Yaml::parseFile($language_file); } } } diff --git a/flextype/Plugins.php b/flextype/Plugins.php index 6031b60e..76bd0034 100755 --- a/flextype/Plugins.php +++ b/flextype/Plugins.php @@ -12,6 +12,7 @@ namespace Flextype; +use Flextype\Component\Filesystem\Filesystem; use Symfony\Component\Yaml\Yaml; class Plugins @@ -55,7 +56,7 @@ class Plugins // Go through... foreach ($plugins_list as $plugin) { - if (Flextype::filesystem()->exists($_plugin = PLUGINS_PATH . '/' . $plugin . '/' . $plugin . '.yml')) { + if (Filesystem::fileExists($_plugin = PLUGINS_PATH . '/' . $plugin . '/' . $plugin . '.yml')) { $plugins_cache_id .= filemtime($_plugin); } } @@ -75,7 +76,7 @@ class Plugins // Go through... foreach ($plugins_list as $plugin) { - if (Flextype::filesystem()->exists($_plugin_manifest = PLUGINS_PATH . '/' . $plugin . '/' . $plugin . '.yml')) { + if (Filesystem::fileExists($_plugin_manifest = PLUGINS_PATH . '/' . $plugin . '/' . $plugin . '.yml')) { $plugin_manifest = Yaml::parseFile($_plugin_manifest); } diff --git a/flextype/Templates.php b/flextype/Templates.php index 35a154ca..31f6e4e7 100644 --- a/flextype/Templates.php +++ b/flextype/Templates.php @@ -12,6 +12,8 @@ namespace Flextype; +use Flextype\Component\Filesystem\Filesystem; + class Templates { @@ -40,7 +42,7 @@ class Templates $template_path = THEMES_PATH . '/' . Config::get('site.theme') . '/' . $template_name . $template_ext; - if (Flextype::filesystem()->exists($template_path)) { + if (Filesystem::fileExists($template_path)) { include $template_path; } else { throw new RuntimeException("Template {$template_name} does not exist."); diff --git a/flextype/Themes.php b/flextype/Themes.php index e72bf2f7..b78a51ad 100644 --- a/flextype/Themes.php +++ b/flextype/Themes.php @@ -12,6 +12,7 @@ namespace Flextype; +use Flextype\Component\Filesystem\Filesystem; use Symfony\Component\Yaml\Yaml; class Themes @@ -56,7 +57,7 @@ class Themes if (Cache::driver()->contains($theme_cache_id)) { Config::set('themes.'.Config::get('site.theme'), Cache::driver()->fetch($theme_cache_id)); } else { - if (Flextype::filesystem()->exists($theme_manifest_file = THEMES_PATH . '/' . $theme . '/' . $theme . '.yml')) { + if (Filesystem::fileExists($theme_manifest_file = THEMES_PATH . '/' . $theme . '/' . $theme . '.yml')) { $theme_manifest = Yaml::parseFile($theme_manifest_file); Config::set('themes.'.Config::get('site.theme'), $theme_manifest); Cache::driver()->save($theme_cache_id, $theme_manifest);