You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am using ionAuth in codeigniter filters and am wondering if calling in each filter (and then in the baseController)
$ionAuth = new \IonAuth\Libraries\IonAuth();
is perhaps not optimal in terms of performance... Does it hit the database each time I do it? How do I get the shared instance of the class in the filters?
I see calling CI libraries as services returns a shared class, so is there any value in defining IonAuth also as a service? If so, maybe someone has it done already and could share?
Sorry if these questions sound silly, I am not very good at OOP...
The text was updated successfully, but these errors were encountered:
Unless I messed something up in my tests, the filters' method before() seems to run before the BaseController method initController, so I cannot define auth class property in the BaseController.
But I have implemented ionAuth as a service this way:
added a service method in the app/Config/Services.php class:
public static function ionAuth($getShared = true)
{
if ($getShared) {
return static::getSharedInstance('ionAuth');
}
return new \IonAuth\Libraries\IonAuth();
}
And then in both BaseController's initController method and the filters I can run
Hi, I am using ionAuth in codeigniter filters and am wondering if calling in each filter (and then in the baseController)
$ionAuth = new \IonAuth\Libraries\IonAuth();
is perhaps not optimal in terms of performance... Does it hit the database each time I do it? How do I get the shared instance of the class in the filters?
I see calling CI libraries as services returns a shared class, so is there any value in defining IonAuth also as a service? If so, maybe someone has it done already and could share?
Sorry if these questions sound silly, I am not very good at OOP...
The text was updated successfully, but these errors were encountered: