hello devs
I have a problem with the codeIgniter4.1.4 services
in the controller I have the following code, in Config/Services getSharedInstance returns an empty array,
namespace App\Controllers;
use Config\Models;
use Config\Services;
use Config\ViewFrontend;
abstract class Frontend extends App
{
public $lang;
public function __construct()
{
parent::__construct();
$this-> language = \ Config \ Services::language()->get ();
$this->lang = $this->language['code'];
....
}
}
in the service /root/App/Config/Services.php I have
class Services extends CoreServices
{
public static function language (string $locale = null, bool $getShared = true): Language
{
if ($ getShared)
{
return static::getSharedInstance ('language', $locale)
-> setLocale ($locale);
}
$ local =! empty ($locale)? $locale: static :: request ()
-> getLocale ();
return new Language ($locale);
}
}
// in the service /root/App/Libraries/Language.php I have
namespace App \ Libraries;
use \ CodeIgniter \ Language \ Language as CI_Language;
use App \ Models \ Languages;
private $DBlanguage;
class Language extends CI_Language
{
public function get (): array
{
return (array) $this->DBlanguage;
}
}
Thanks for your help
Gabriel