yii2-usuario
yii2-usuario copied to clipboard
override SocialNetworkAccount.php
I'm using this Yii2 plugin for my user model
https://yii2-usuario.readthedocs.io/en/latest/
In my main.php i have this.
'user' => [
'class' => Da\User\Module::class,
'enableEmailConfirmation' => true,
'classMap' => [
'User' => 'app\models\user\Model\User',
'SocialNetworkAccount' => 'app\models\user\Model\SocialNetworkAccount',
],
then in the directory models/user/Model i have this
namespace app\models\user\Model;
use Yii;
use app\models\user\Model\User;
use Da\User\Model\SocialNetworkAccount as BaseClass;
class SocialNetworkAccount extends BaseClass
{
public function connect(User $user)
{
return $this->updateAttributes(
[
'username' => null,
'firstname' => $user->firstname,
'lastname' => $user->lastname,
'email' => null,
'code' => null,
'user_id' => $user->id,
]
);
}
}
but when i go to my login page i get this error
Declaration of app\models\user\Model\SocialNetworkAccount::connect(app\models\user\Model\User $user) must be compatible with Da\User\Model\SocialNetworkAccount::connect(Da\User\Model\User $user)
i tried following the tutorial here to override classes, but no luck
https://yii2-usuario.readthedocs.io/en/latest/enhancing-and-overriding/overriding-classes/
what am i doing wrong here? thanks
UPDATE:
i tried this
public function connect(\Da\User\Model\User $user)
don't get the error anymore, but now i noticed it doesn't add firstname and lastname
in my user model rules i have this
public function rules()
{
return [
...
[['email', 'firstname', 'lastname'], 'safe'],
]
}