Config/Services getSharedInstance returns an empty array |
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 (10-15-2021, 01:17 AM)BYOOS Wrote: // in the service /root/App/Libraries/Language.php I have It seems $this->DBlanguage is an empty array.
we have these layers controller service entity model migrtation seeder
for problem use config not service use service like that PHP Code: <?php namespace Modules\Auth\Config; PHP Code: <?php namespace Modules\Auth\Controllers;
Enlightenment Is Freedom
Good evening,
thank you for your very interesting answers, I specify that the proposed code is an extract of a more important application and the author uses the end-to-end services, I dry like an old squid... to note PHP 8.0.11 codeigniter 4.1.4 app https://github.com/khodakhah/nodcms |
Welcome Guest, Not a member yet? Register Sign In |