From dacbcdbe730ef6a4b8c3b9a95cfff5be7f7b5589 Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 23 Mar 2018 00:34:16 +0300 Subject: [PATCH] Code cleanup and refactoring #5 --- flextype/Cache.php | 4 ++- flextype/Config.php | 10 +++--- flextype/Events.php | 8 +++-- flextype/Filters.php | 4 ++- flextype/Flextype.php | 68 ++++++++++++++++++++++++++++----------- flextype/I18n.php | 8 +++-- flextype/Markdown.php | 8 +++-- flextype/Pages.php | 14 ++++---- flextype/Plugins.php | 8 +++-- flextype/Shortcodes.php | 10 +++--- flextype/Templates.php | 6 ++-- flextype/Themes.php | 12 +++---- flextype/boot/defines.php | 4 ++- index.php | 4 ++- 14 files changed, 111 insertions(+), 57 deletions(-) diff --git a/flextype/Cache.php b/flextype/Cache.php index 03be9e78..0446b278 100755 --- a/flextype/Cache.php +++ b/flextype/Cache.php @@ -1,4 +1,4 @@ - + * @link http://flextype.org + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flextype; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; use Url; use Session; - /** - * @package Flextype - * - * @author Romanenko Sergey / Awilum - * @link http://flextype.org - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - class Flextype { /** @@ -26,7 +28,7 @@ class Flextype protected static $instance = null; /** - * Filesystem + * Filesystem object * * @var object * @access public @@ -34,7 +36,7 @@ class Flextype public static $filesystem = null; /** - * Finder + * Finder object * * @var object * @access public @@ -65,8 +67,20 @@ class Flextype */ protected function __construct() { + static::app(); + } + /** + * Application. + * + * @access protected + */ + protected static function app() + { + // Init Finder static::$finder = new Finder(); + + // Init Filesystem static::$filesystem = new Filesystem(); // Init Config @@ -115,20 +129,38 @@ class Flextype // Init Plugins Plugins::init(); - // Render current page + // Init Pages Pages::init(); // Flush (send) the output buffer and turn off output buffering ob_end_flush(); } + /** + * Returns filesystem object + * + * @access public + * @return object + */ + public static function filesystem() + { + return static::$filesystem; + } + + /** + * Returns finder object + * + * @access public + * @return object + */ + public static function finder() + { + return static::$finder; + } + /** * Initialize Flextype Application * - * - * Rawium::init(); - * - * * @access public * @return object */ diff --git a/flextype/I18n.php b/flextype/I18n.php index e1fc26a6..840d909a 100644 --- a/flextype/I18n.php +++ b/flextype/I18n.php @@ -1,6 +1,4 @@ -exists($template_path)) { + if (Flextype::filesystem()->exists($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 7b01da29..2211ef33 100644 --- a/flextype/Themes.php +++ b/flextype/Themes.php @@ -1,6 +1,4 @@ - - * Themes::init(); - * - * * @access public * @return object */ diff --git a/flextype/boot/defines.php b/flextype/boot/defines.php index 6de5b395..b76a107c 100755 --- a/flextype/boot/defines.php +++ b/flextype/boot/defines.php @@ -1,4 +1,4 @@ -