From 3f74ba88c2b44189e6df07fee2f1e8014a9bb7f5 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Wed, 31 Oct 2018 12:12:15 -0400 Subject: [PATCH] Move delimiter props and functions move left and right delimiter functions and properties to Render class. --- src/App.php | 40 --------------------------------- src/Core/Renderer.php | 41 ++++++++++++++++++++++++++++++++++ src/Render/FriendicaSmarty.php | 5 +++-- 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/App.php b/src/App.php index a301fa0b29..deb15f702c 100644 --- a/src/App.php +++ b/src/App.php @@ -162,14 +162,6 @@ class App public $template_engine_instance = []; public $process_id; public $queue; - private $ldelim = [ - 'internal' => '', - 'smarty3' => '{{' - ]; - private $rdelim = [ - 'internal' => '', - 'smarty3' => '}}' - ]; private $scheme; private $hostname; @@ -924,38 +916,6 @@ class App $this->theme['template_engine'] = $engine; } - /** - * Gets the right delimiter for a template engine - * - * Currently: - * Internal = '' - * Smarty3 = '{{' - * - * @param string $engine The template engine (default is Smarty3) - * - * @return string the right delimiter - */ - public function getTemplateLeftDelimiter($engine = 'smarty3') - { - return $this->ldelim[$engine]; - } - - /** - * Gets the left delimiter for a template engine - * - * Currently: - * Internal = '' - * Smarty3 = '}}' - * - * @param string $engine The template engine (default is Smarty3) - * - * @return string the left delimiter - */ - public function getTemplateRightDelimiter($engine = 'smarty3') - { - return $this->rdelim[$engine]; - } - /** * Saves a timestamp for a value - f.e. a call * Necessary for profiling Friendica diff --git a/src/Core/Renderer.php b/src/Core/Renderer.php index 70f98059b1..378652fe26 100644 --- a/src/Core/Renderer.php +++ b/src/Core/Renderer.php @@ -15,6 +15,15 @@ use Friendica\Render\FriendicaSmarty; */ class Renderer extends BaseObject { + private static $ldelim = [ + 'internal' => '', + 'smarty3' => '{{' + ]; + private static $rdelim = [ + 'internal' => '', + 'smarty3' => '}}' + ]; + /** * @brief This is our template processor * @@ -69,4 +78,36 @@ class Renderer extends BaseObject return $template; } + + /** + * Gets the right delimiter for a template engine + * + * Currently: + * Internal = '' + * Smarty3 = '{{' + * + * @param string $engine The template engine (default is Smarty3) + * + * @return string the right delimiter + */ + public static function getTemplateLeftDelimiter($engine = 'smarty3') + { + return self::$ldelim[$engine]; + } + + /** + * Gets the left delimiter for a template engine + * + * Currently: + * Internal = '' + * Smarty3 = '}}' + * + * @param string $engine The template engine (default is Smarty3) + * + * @return string the left delimiter + */ + public static function getTemplateRightDelimiter($engine = 'smarty3') + { + return self::$rdelim[$engine]; + } } diff --git a/src/Render/FriendicaSmarty.php b/src/Render/FriendicaSmarty.php index 2052aa9e87..e544a76d1b 100644 --- a/src/Render/FriendicaSmarty.php +++ b/src/Render/FriendicaSmarty.php @@ -5,6 +5,7 @@ namespace Friendica\Render; use Smarty; +use Friendica\Core\Renderer; /** * Friendica extension of the Smarty3 template engine @@ -38,8 +39,8 @@ class FriendicaSmarty extends Smarty $this->setConfigDir('view/smarty3/config/'); $this->setCacheDir('view/smarty3/cache/'); - $this->left_delimiter = $a->getTemplateLeftDelimiter('smarty3'); - $this->right_delimiter = $a->getTemplateRightDelimiter('smarty3'); + $this->left_delimiter = Renderer::getTemplateLeftDelimiter('smarty3'); + $this->right_delimiter = Renderer::getTemplateRightDelimiter('smarty3'); // Don't report errors so verbosely $this->error_reporting = E_ALL & ~E_NOTICE; -- 2.39.5