Jump to content

Edit History

sococa

sococa

Hello @Andrei H,


Thank you, you are divine. My comment was absolutely necessary ;) 

It works :)  However, i have 2 questions.

1/ How did you find this ?? I didn't see all this in the doc. Nothing about ServiceLocator.

2/ You said : "Also, if you look into the ServiceLocator class, you will see that it will be removed at some point, therefore a better way to do it is to manually inject the service via the __construct method or via a setter."
So, i need to use _construct instead of ServiceLocator::get(SendcodeService::class) ? I need to place ServiceLocator::get(SendcodeService::class) in this construct ?

    public function __construct()
    {
        $this->name = 'lebruntwofa';
        $this->tab = 'others';
        $this->version = '1.0.0';
        $this->author = 'lebrun';

        $this->need_instance = 1;
        $this->ps_versions_compliancy = [
            'min' => '8.0.0',
            'max' => '8.99.99',
        ];
        $this->bootstrap = true;

        parent::__construct();

        $this->confirmUninstall = $this->l('Do you still you want to uninstall this module?');
        $this->displayName = $this->l('Lebrun Two Factor Authentification');
        $this->description = $this->l('Ajoute une authentification par code à la connexion des clients');
    }

Big thanks again.

sococa

sococa

Hello @Andrei H,


Thank you, you are divine. My comment was absolutely necessary ;) 

It works :)  However, i have 2 questions.

1/ How did you find this ?? I didn't see all this in the doc. Nothing about ServiceLocator.

2/ You said : "Also, if you look into the ServiceLocator class, you will see that it will be removed at some point, therefore a better way to do it is to manually inject the service via the __construct method or via a setter."
So, i need to use _construct instead of ServiceLocator::get(SendcodeService::class) ? I need to place ServiceLocator::get(SendcodeService::class) in this construct 

×
×
  • Create New...