1
0
mirror of https://github.com/flextype/flextype.git synced 2025-01-17 20:58:29 +01:00

define CONSTANTS in PHP7 style

This commit is contained in:
Awilum 2018-05-15 14:22:24 +03:00
parent dc99272fc0
commit f30200a579
5 changed files with 21 additions and 21 deletions

View File

@ -84,7 +84,7 @@ class Cache
static::$now = time();
// Create cache key to allow invalidate all cache on configuration changes.
static::$key = (Registry::get('site.cache.prefix') ?? 'flextype') . '-' . md5(ROOT_DIR . Flextype::VERSION);
static::$key = (Registry::get('site.cache.prefix') ?? 'flextype') . '-' . md5(PATH['site'] . Flextype::VERSION);
// Get Cache Driver
static::$driver = static::getCacheDriver();
@ -166,7 +166,7 @@ class Cache
break;
default:
// Create doctrine cache directory if its not exists
!Filesystem::fileExists($cache_directory = CACHE_PATH . '/doctrine/') and Filesystem::createDir($cache_directory);
!Filesystem::fileExists($cache_directory = PATH['cache'] . '/doctrine/') and Filesystem::createDir($cache_directory);
$driver = new DoctrineCache\FilesystemCache($cache_directory);
break;
}
@ -243,7 +243,7 @@ class Cache
function_exists('opcache_reset') and @opcache_reset();
// Remove cache dir
Filesystem::deleteDir(CACHE_PATH . '/doctrine/');
Filesystem::deleteDir(PATH['cache'] . '/doctrine/');
}
/**

View File

@ -114,13 +114,13 @@ class Content
if ($url) {
$file = $url;
} else {
$file = PAGES_PATH . '/' . Registry::get('site.pages.main') . '/' . 'page.md';
$file = PATH['pages'] . '/' . Registry::get('site.pages.main') . '/' . 'page.md';
}
} else {
if ($url) {
$file = PAGES_PATH . '/' . $url . '/page.md';
$file = PATH['pages'] . '/' . $url . '/page.md';
} else {
$file = PAGES_PATH . '/' . Registry::get('site.pages.main') . '/' . 'page.md';
$file = PATH['pages'] . '/' . Registry::get('site.pages.main') . '/' . 'page.md';
}
}
@ -128,7 +128,7 @@ class Content
if (Filesystem::fileExists($file)) {
$file = $file;
} else {
$file = PAGES_PATH . '/404/page.md';
$file = PATH['pages'] . '/404/page.md';
Http::setResponseStatus(404);
}
@ -166,7 +166,7 @@ class Content
if ($url == '') {
// Get pages list
$pages_list = Filesystem::getFilesList(PAGES_PATH, 'md');
$pages_list = Filesystem::getFilesList(PATH['pages'] . '/' , 'md');
// Create pages array from pages list
foreach ($pages_list as $key => $page) {
@ -176,7 +176,7 @@ class Content
} else {
// Get pages list
$pages_list = Filesystem::getFilesList(PAGES_PATH . '/' . $url, 'md');
$pages_list = Filesystem::getFilesList(PATH['pages'] . '/' . $url, 'md');
// Create pages array from pages list and ignore current requested page
foreach ($pages_list as $key => $page) {
@ -235,7 +235,7 @@ class Content
$_page = Yaml::parse(Content::processContentShortcodes($page_frontmatter));
// Create page url item
$url = str_replace(PAGES_PATH, Http::getBaseUrl(), $file);
$url = str_replace(PATH['pages'] , Http::getBaseUrl(), $file);
$url = str_replace('page.md', '', $url);
$url = str_replace('.md', '', $url);
$url = str_replace('\\', '/', $url);

View File

@ -66,7 +66,7 @@ class Flextype
Registry::set('site', []);
// Set site items if site config exists
if (Filesystem::fileExists($site_config = CONFIG_PATH . '/' . 'site.yaml')) {
if (Filesystem::fileExists($site_config = PATH['config'] . '/' . 'site.yaml')) {
Registry::set('site', Yaml::parseFile($site_config));
} else {
throw new \RuntimeException("Flextype site config file does not exist.");

View File

@ -99,13 +99,13 @@ class Plugins
// Go through...
foreach ($plugins_list as $plugin) {
if (Filesystem::fileExists($_plugin = PLUGINS_PATH . '/' . $plugin . '/' . $plugin . '.yaml')) {
if (Filesystem::fileExists($_plugin = PATH['plugins'] . '/' . $plugin . '/' . $plugin . '.yaml')) {
$plugins_cache_id .= filemtime($_plugin);
}
}
// Create Unique Cache ID for Plugins
$plugins_cache_id = md5('plugins' . PLUGINS_PATH . $plugins_cache_id);
$plugins_cache_id = md5('plugins' . PATH['plugins'] . '/' . $plugins_cache_id);
}
// Get plugins list from cache or scan plugins folder and create new plugins cache item
@ -119,7 +119,7 @@ class Plugins
// Go through...
foreach ($plugins_list as $plugin) {
if (Filesystem::fileExists($_plugin_manifest = PLUGINS_PATH . '/' . $plugin . '/' . $plugin . '.yaml')) {
if (Filesystem::fileExists($_plugin_manifest = PATH['plugins'] . '/' . $plugin . '/' . $plugin . '.yaml')) {
$plugin_manifest = Yaml::parseFile($_plugin_manifest);
}
@ -135,7 +135,7 @@ class Plugins
if (is_array($plugins_list) && count($plugins_list) > 0) {
foreach (static::$locales as $locale => $locale_title) {
foreach ($plugins_list as $plugin) {
$language_file = PLUGINS_PATH . '/' . $plugin . '/languages/' . $locale . '.yaml';
$language_file = PATH['plugins'] . '/' . $plugin . '/languages/' . $locale . '.yaml';
if (Filesystem::fileExists($language_file)) {
I18n::add($plugin, $locale, Yaml::parseFile($language_file));
}
@ -147,7 +147,7 @@ class Plugins
if (is_array(Registry::get('plugins')) && count(Registry::get('plugins')) > 0) {
foreach (Registry::get('plugins') as $plugin_name => $plugin) {
if (Registry::get('plugins.'.$plugin_name.'.enabled')) {
include_once PLUGINS_PATH .'/'. $plugin_name .'/'. $plugin_name . '.php';
include_once PATH['plugins'] . '/' . $plugin_name .'/'. $plugin_name . '.php';
}
}
}

View File

@ -55,13 +55,13 @@ class Themes
Registry::set('themes', []);
// Create Unique Cache ID for Theme
$theme_cache_id = md5('theme' . THEMES_PATH . $theme);
$theme_cache_id = md5('theme' . PATH['themes'] . $theme);
// Get Theme mafifest file and write to site.themes array
if (Cache::driver()->contains($theme_cache_id)) {
Registry::set('themes.'.Registry::get('site.theme'), Cache::driver()->fetch($theme_cache_id));
} else {
if (Filesystem::fileExists($theme_manifest_file = THEMES_PATH . '/' . $theme . '/' . $theme . '.yaml')) {
if (Filesystem::fileExists($theme_manifest_file = PATH['themes'] . '/' . $theme . '/' . $theme . '.yaml')) {
$theme_manifest = Yaml::parseFile($theme_manifest_file);
Registry::set('themes.'.Registry::get('site.theme'), $theme_manifest);
Cache::driver()->save($theme_cache_id, $theme_manifest);
@ -82,10 +82,10 @@ class Themes
{
// Set view file
// From current theme folder or from plugin folder
if (Filesystem::fileExists(THEMES_PATH . '/' . Registry::get('site.theme') . '/views/' . $template . View::$view_ext)) {
$template = THEMES_PATH . '/' . Registry::get('site.theme') . '/views/' . $template;
if (Filesystem::fileExists(PATH['themes'] . '/' . Registry::get('site.theme') . '/views/' . $template . View::$view_ext)) {
$template = PATH['themes'] . '/' . Registry::get('site.theme') . '/views/' . $template;
} else {
$template = PLUGINS_PATH . '/' . $template;
$template = PATH['plugins'] . '/' . $template;
}
// Return template