Skip to content

Commit

Permalink
keep deprecating loadLang
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasKovacs committed Apr 28, 2023
1 parent 0a77b74 commit 9f69217
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
27 changes: 2 additions & 25 deletions app/Core/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use App\Libraries\Page;
use App\Libraries\Users;
use CiLang;
use Exception;

abstract class BaseController
{
Expand All @@ -33,30 +32,8 @@ public function __construct()
/**
* @param string|array $languageFile
*/
public function loadLang($languageFile): void
protected function loadLang($languageFile): void
{
try {
// require langugage library
$langPath = XGP_ROOT . LIB_PATH . 'Ci' . DIRECTORY_SEPARATOR . 'CiLang.php';

if (!file_exists($langPath)) {
// not found
throw new Exception('Language file "' . $languageFile . '" not defined');
return;
}

// required by the library
if (!defined('BASEPATH')) {
define('BASEPATH', XGP_ROOT . RESOURCES_PATH);
}

// use CI library
require_once $langPath;

$this->langs = new CiLang();
$this->langs->load($languageFile, DEFAULT_LANG);
} catch (Exception $e) {
die('Fatal error: ' . $e->getMessage());
}
$this->langs = (new Language())->loadLang($languageFile, true);
}
}
10 changes: 5 additions & 5 deletions app/Core/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ class Language
private CiLang $langs;

/**
* @param string|array $language_file
* @param string|array $languageFile
*
* @return mixed
*/
public function loadLang($language_file, $return = false)
public function loadLang($languageFile, bool $return = false)
{
try {
// require langugage library
$langPath = XGP_ROOT . LIB_PATH . 'Ci' . DIRECTORY_SEPARATOR . 'CiLang.php';

if (!file_exists($langPath)) {
// not found
throw new Exception('Language file "' . $language_file . '" not defined');
throw new Exception('Language file "' . $languageFile . '" not defined');
return;
}

Expand All @@ -36,12 +36,12 @@ public function loadLang($language_file, $return = false)

if ($return) {
$lang = new CiLang();
$lang->load($language_file, DEFAULT_LANG);
$lang->load($languageFile, DEFAULT_LANG);
return $lang;
}

$this->langs = new CiLang();
$this->langs->load($language_file, DEFAULT_LANG);
$this->langs->load($languageFile, DEFAULT_LANG);
} catch (Exception $e) {
die('Fatal error: ' . $e->getMessage());
}
Expand Down

0 comments on commit 9f69217

Please sign in to comment.