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

Using Flextype Components

This commit is contained in:
Awilum
2018-04-13 12:08:48 +03:00
parent 06d544a2cd
commit 2367bb65da
6 changed files with 17 additions and 11 deletions

View File

@@ -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/');
}
/**

View File

@@ -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.");
}

View File

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

View File

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

View File

@@ -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.");

View File

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