From ff21f8e69707ae45893f1e3be73cdfd30767859b Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 16 Mar 2018 20:54:32 +0300 Subject: [PATCH] Code cleanup and refactoring #5 --- rawilum/Filters.php | 2 +- rawilum/Markdown.php | 2 +- rawilum/Pages.php | 6 ++- rawilum/Plugins.php | 2 +- rawilum/Rawilum.php | 99 +++++++------------------------------------- 5 files changed, 21 insertions(+), 90 deletions(-) diff --git a/rawilum/Filters.php b/rawilum/Filters.php index 561c6016..fe9a4b3d 100755 --- a/rawilum/Filters.php +++ b/rawilum/Filters.php @@ -99,7 +99,7 @@ class Filters * @return boolean */ public static function addListener($filter_name, $function_to_add, $priority = 10, $accepted_args = 1) - { + { // Redefine arguments $filter_name = (string) $filter_name; $function_to_add = $function_to_add; diff --git a/rawilum/Markdown.php b/rawilum/Markdown.php index 7f01a3e4..bb9db76c 100644 --- a/rawilum/Markdown.php +++ b/rawilum/Markdown.php @@ -33,7 +33,7 @@ class Markdown * @param string $content Content to parse * @return string Formatted content */ - public static function parse($content) + public static function parse(string $content) : string { !static::$markdown and static::$markdown = new ParsedownExtra(); diff --git a/rawilum/Pages.php b/rawilum/Pages.php index 612941ff..15ae3c7b 100755 --- a/rawilum/Pages.php +++ b/rawilum/Pages.php @@ -26,6 +26,8 @@ class Pages protected static $instance = null; /** + * Page + * * @var Page */ public static $page; @@ -125,7 +127,7 @@ class Pages /** * Get page */ - public static function getPage($url = '', $raw = false, $url_abs = false) + public static function getPage(string $url = '', bool $raw = false, bool $url_abs = false) { $file = static::finder($url, $url_abs); @@ -143,7 +145,7 @@ class Pages return static::$page; } - public static function parseContent($content) + public static function parseContent(string $content) : string { $content = Shortcodes::parse($content); $content = Markdown::parse($content); diff --git a/rawilum/Plugins.php b/rawilum/Plugins.php index 93748948..3c5424e9 100755 --- a/rawilum/Plugins.php +++ b/rawilum/Plugins.php @@ -56,7 +56,7 @@ class Plugins } /** - * Initialize Rawilum I18n + * Initialize Rawilum Plugins * * * Plugins::init(); diff --git a/rawilum/Rawilum.php b/rawilum/Rawilum.php index 9564b9e8..1f280f79 100755 --- a/rawilum/Rawilum.php +++ b/rawilum/Rawilum.php @@ -18,16 +18,28 @@ use Session; class Rawilum { /** - * An instance of the Fansoro class + * An instance of the Rawilum class * * @var object * @access protected */ protected static $instance = null; + /** + * Filesystem + * + * @var object + * @access public + */ public static $filesystem = null; + + /** + * Finder + * + * @var object + * @access public + */ public static $finder = null; - public static $parsedown = null; /** * Protected clone method to enforce singleton behavior. @@ -46,89 +58,6 @@ class Rawilum */ const VERSION = '0.0.0'; - /** - * Init Rawilum Application - * - * @access protected - */ - /*protected static function init() - { - // Create container - $container = new static(); - - // Define markdown service - $container['markdown'] = function ($c) { - return new ParsedownExtra(); - }; - - // Define filesystem service - $container['filesystem'] = function ($c) { - return new Filesystem(); - }; - - // Define finder service - $container['finder'] = function ($c) { - return new Finder(); - }; - - // Define cache service - $container['cache'] = function ($c) { - return new Cache($c); - }; - - // Define config service - $container['config'] = function ($c) { - return new Config($c); - }; - - // Define shortcodes service - $container['shortcodes'] = function ($c) { - return new Shortcodes($c); - }; - - // Define events service - $container['events'] = function ($c) { - return new Events($c); - }; - - // Define filters service - $container['filters'] = function ($c) { - return new Filters($c); - }; - - // Define i18n service - $container['i18n'] = function ($c) { - return new I18n($c); - }; - - // Define plugins service - $container['plugins'] = function ($c) { - return new Plugins($c); - }; - - // Define pages service - $container['pages'] = function ($c) { - return new Pages($c); - }; - - // Define themes service - $container['themes'] = function ($c) { - return new Themes($c); - }; - - // Init I18n - $container['i18n']->init(); - - // Init Plugins - $container['plugins']->init(); - - // Get current page - $container['pages']->getPage(Url::getUriString()); - - // Return container - return $container; - }*/ - /** * Constructor. *