2amigos / yii2-usuario

Highly customizable and extensible user management, authentication, and authorization Yii2 extension
https://github.com/2amigos/yii2-usuario
Other
294 stars 142 forks source link

How does this work? #440

Closed WeeSee closed 2 years ago

WeeSee commented 2 years ago

In this line

https://github.com/2amigos/yii2-usuario/blob/master/src/User/Controller/AdminController.php#L294

if ($this->make(UserBlockService::class, [$user, $event, $this])->run()) {

there is an instance of class UserBlockService created with three parameters ´$user, $event, $this´.

But in the constructor of the class UserBlockService

https://github.com/2amigos/yii2-usuario/blob/504e18c855be619f2e4812f06f43a824370644f6/src/User/Service/UserBlockService.php#L27

public function __construct(
    User $model,
    UserEvent $event,
    AdminController $controller,
    SecurityHelper $securityHelper
) {
    $this->model = $model;
    $this->event = $event;
    $this->controller = $controller;
    $this->securityHelper = $securityHelper;
}

four parameters are required. Where does $securityHelper get it's value from?

How does this work?

TonisOrmisson commented 2 years ago

di container

            // helpers
            $di->set(Helper\AuthHelper::class);
            $di->set(Helper\GravatarHelper::class);
            $di->set(Helper\SecurityHelper::class);
            $di->set(Helper\TimezoneHelper::class);

https://github.com/2amigos/yii2-usuario/blob/master/src/User/Bootstrap.php#L93