mirror of
https://github.com/flextype/flextype.git
synced 2025-08-13 16:44:36 +02:00
Code cleanup and refactoring #5
This commit is contained in:
@@ -62,11 +62,22 @@ class Cache
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Protected constructor since this is a static class.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
static::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init Cache
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected static function init() : void
|
||||
{
|
||||
// Set current time
|
||||
static::$now = time();
|
||||
@@ -269,12 +280,13 @@ class Cache
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Flextype Cache
|
||||
* Return the Cache instance.
|
||||
* Create it if it's not already created.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function init()
|
||||
public static function instance()
|
||||
{
|
||||
return !isset(self::$instance) and self::$instance = new Cache();
|
||||
}
|
||||
|
@@ -45,11 +45,22 @@ class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Protected constructor since this is a static class.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
static::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init Config
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
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));
|
||||
@@ -95,11 +106,13 @@ class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Flextype Config
|
||||
* Return the Config instance.
|
||||
* Create it if it's not already created.
|
||||
*
|
||||
* @access public
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function init()
|
||||
public static function instance()
|
||||
{
|
||||
return !isset(self::$instance) and self::$instance = new Config();
|
||||
}
|
||||
|
@@ -76,14 +76,14 @@ class Flextype
|
||||
*/
|
||||
protected static function app() : void
|
||||
{
|
||||
// Init Finder
|
||||
// Create Finder Instance
|
||||
static::$finder = new Finder();
|
||||
|
||||
// Init Filesystem
|
||||
// Create Filesystem Instance
|
||||
static::$filesystem = new Filesystem();
|
||||
|
||||
// Init Config
|
||||
Config::init();
|
||||
// Create Cache Instance
|
||||
Config::instance();
|
||||
|
||||
// Turn on output buffering
|
||||
ob_start();
|
||||
@@ -113,23 +113,23 @@ class Flextype
|
||||
// Start the session
|
||||
Session::start();
|
||||
|
||||
// Init Cache
|
||||
Cache::init();
|
||||
// Create Cache Instance
|
||||
Cache::instance();
|
||||
|
||||
// Init I18n
|
||||
I18n::init();
|
||||
// Create I18n Instance
|
||||
I18n::instance();
|
||||
|
||||
// Init Shortcodes
|
||||
Shortcodes::init();
|
||||
// Create Shortcodes Instance
|
||||
Shortcodes::instance();
|
||||
|
||||
// Init Themes
|
||||
Themes::init();
|
||||
// Create Themes Instance
|
||||
Themes::instance();
|
||||
|
||||
// Init Plugins
|
||||
Plugins::init();
|
||||
// Create Plugins Instance
|
||||
Plugins::instance();
|
||||
|
||||
// Init Pages
|
||||
Pages::init();
|
||||
// Create Pages Instance
|
||||
Pages::instance();
|
||||
|
||||
// Flush (send) the output buffer and turn off output buffering
|
||||
ob_end_flush();
|
||||
|
@@ -81,9 +81,22 @@ class I18n
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct
|
||||
* Protected constructor since this is a static class.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
static::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init I18n
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected static function init() : void
|
||||
{
|
||||
|
||||
// Get Plugins and Site Locales list
|
||||
@@ -130,12 +143,13 @@ class I18n
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Flextype I18n
|
||||
* Return the I18n instance.
|
||||
* Create it if it's not already created.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function init()
|
||||
public static function instance()
|
||||
{
|
||||
return !isset(self::$instance) and self::$instance = new I18n();
|
||||
}
|
||||
|
@@ -34,11 +34,22 @@ class Pages
|
||||
public static $page;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Protected constructor since this is a static class.
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
static::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init Pages
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected static function init() : void
|
||||
{
|
||||
// The page is not processed and not sent to the display.
|
||||
Events::dispatch('onPageBeforeRender');
|
||||
@@ -230,12 +241,13 @@ class Pages
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Flextype Pages
|
||||
* Return the Pages instance.
|
||||
* Create it if it's not already created.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function init()
|
||||
public static function instance()
|
||||
{
|
||||
return !isset(self::$instance) and self::$instance = new Pages();
|
||||
}
|
||||
|
@@ -24,11 +24,22 @@ class Plugins
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Init Plugins
|
||||
* Protected constructor since this is a static class.
|
||||
*
|
||||
* @access public
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
static::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init Plugins
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected static function init() : void
|
||||
{
|
||||
// Plugin manifest
|
||||
$plugin_manifest = [];
|
||||
@@ -89,12 +100,13 @@ class Plugins
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Flextype Plugins
|
||||
* Return the Plugins instance.
|
||||
* Create it if it's not already created.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function init()
|
||||
public static function instance()
|
||||
{
|
||||
return !isset(self::$instance) and self::$instance = new Plugins();
|
||||
}
|
||||
|
@@ -38,6 +38,17 @@ class Shortcodes
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
static::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init Shortcodes
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected static function init() : void
|
||||
{
|
||||
// Set driver
|
||||
static::$driver = new ShortcodeFacade();
|
||||
@@ -70,12 +81,13 @@ class Shortcodes
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Flextype Shortcodes
|
||||
* Return the Shortcodes instance.
|
||||
* Create it if it's not already created.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function init()
|
||||
public static function instance()
|
||||
{
|
||||
return !isset(self::$instance) and self::$instance = new Shortcodes();
|
||||
}
|
||||
|
@@ -24,12 +24,22 @@ class Themes
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Init Themes
|
||||
* Protected constructor since this is a static class.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
static::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Init Themes
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected static function init() : void
|
||||
{
|
||||
// Theme Manifest
|
||||
$theme_manifest = [];
|
||||
@@ -55,12 +65,13 @@ class Themes
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Flextype Themes
|
||||
* Return the Themes instance.
|
||||
* Create it if it's not already created.
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function init()
|
||||
public static function instance()
|
||||
{
|
||||
return !isset(self::$instance) and self::$instance = new Themes();
|
||||
}
|
||||
|
Reference in New Issue
Block a user