From b41efea3320edd1f3bdec75247ea0e67c4987916 Mon Sep 17 00:00:00 2001 From: Tan Nguyen Date: Sat, 4 Nov 2023 16:19:20 +0700 Subject: [PATCH] fix: update condition for functions that conflict with laravel framework --- common/helpers.php | 56 +++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/common/helpers.php b/common/helpers.php index e8f60e6..b2067b9 100755 --- a/common/helpers.php +++ b/common/helpers.php @@ -105,32 +105,38 @@ function tgn_convert_action_name(string $action): string } } -if (!function_exists('config')) { - /** - * Return config value by string - * - * @param string $string - * - * @return mixed - */ - function config(string $string): mixed - { - return (new ConfigHelper())->execConfig($string); +if (!class_exists('Illuminate\Foundation\Application')) { + if (!function_exists('config')) { + /** + * Return config value by string + * + * @param string $string + * + * @return mixed + */ + function config(string $string): mixed + { + return (new ConfigHelper())->execConfig($string); + } } -} -if (!function_exists('view')) { - /** - * Get view template - * - * @param string $partialPath - * @param array $data - * - * @return null|string - */ - function view(string $partialPath, array $data = []): null|string - { - $content = (new ConfigHelper())->getTemplateData($partialPath, $data); - return $content ?: null; + if (!function_exists('view')) { + /** + * Get view template + * + * @param string $partialPath + * @param array $data + * + * @return null|string + */ + function view(string $partialPath, array $data = []): null|string + { + $content = (new ConfigHelper())->getTemplateData( + $partialPath, + $data + ); + + return $content ?: null; + } } }