1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-09 06:36:52 +02:00

Code cleanup and refactoring #5

This commit is contained in:
Awilum
2018-03-13 01:22:01 +03:00
parent c670840fcd
commit 934c47ffbf
5 changed files with 23 additions and 19 deletions

View File

@@ -104,15 +104,19 @@ class Cache
break;
case 'memcache':
$memcache = new \Memcache();
$memcache->connect($this->rawilum['config']->get('site.cache.memcache.server', 'localhost'),
$this->rawilum['config']->get('site.cache.memcache.port', 11211));
$memcache->connect(
$this->rawilum['config']->get('site.cache.memcache.server', 'localhost'),
$this->rawilum['config']->get('site.cache.memcache.port', 11211)
);
$driver = new \Doctrine\Common\Cache\MemcacheCache();
$driver->setMemcache($memcache);
break;
case 'redis':
$redis = new \Redis();
$redis->connect($this->rawilum['config']->get('site.cache.redis.server', 'localhost'),
$this->rawilum['config']->get('site.cache.redis.port', 6379));
$redis->connect(
$this->rawilum['config']->get('site.cache.redis.server', 'localhost'),
$this->rawilum['config']->get('site.cache.redis.port', 6379)
);
$driver = new \Doctrine\Common\Cache\RedisCache();
$driver->setRedis($redis);
break;

View File

@@ -46,17 +46,17 @@ class Pages
// If url is empty that its a homepage
if ($url_abs) {
if ($url) {
$file = $url;
} else {
$file = PAGES_PATH . '/' . $this->rawilum['config']->get('site.pages.main') . '/' . 'index.md';
}
if ($url) {
$file = $url;
} else {
$file = PAGES_PATH . '/' . $this->rawilum['config']->get('site.pages.main') . '/' . 'index.md';
}
} else {
if ($url) {
$file = PAGES_PATH . '/' . $url . '/index.md';
} else {
$file = PAGES_PATH . '/' . $this->rawilum['config']->get('site.pages.main') . '/' . 'index.md';
}
if ($url) {
$file = PAGES_PATH . '/' . $url . '/index.md';
} else {
$file = PAGES_PATH . '/' . $this->rawilum['config']->get('site.pages.main') . '/' . 'index.md';
}
}
// Get 404 page if file not exists
@@ -83,7 +83,8 @@ class Pages
$template_path = THEMES_PATH . '/' . $site_theme . '/' . $template_name . $template_ext;
if ($this->rawilum['filesystem']->exists($template_path)) {
include $template_path;
$this->rawilum['themes']->renderPage($page);
//include $template_path;
} else {
throw new RuntimeException("Template {$template_name} does not exist.");
}
@@ -123,7 +124,6 @@ class Pages
*/
public function getPage($url = '', $raw = false, $url_abs = false)
{
$file = $this->finder($url, $url_abs);
if ($raw) {

View File

@@ -32,7 +32,8 @@ class Plugins
* @access public
* @return mixed
*/
public function init() {
public function init()
{
// Plugin manifest
$plugin_manifest = [];

View File

@@ -84,7 +84,7 @@ class Rawilum extends Container
};
$container['pages'] = function ($c) {
return new Pages($c);
return new Pages($c);
};
$container['themes'] = function ($c) {

View File

@@ -46,5 +46,4 @@ class Themes
throw new RuntimeException("Template {$template_name} does not exist.");
}
}
}