Add trait to support new interface in a backward compatible way
This commit is contained in:
@ -12,10 +12,14 @@
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
use Da\User\Traits\AuthClientUserIdTrait;
|
||||
use yii\authclient\clients\Facebook as BaseFacebook;
|
||||
|
||||
class Facebook extends BaseFacebook implements AuthClientInterface
|
||||
{
|
||||
|
||||
use AuthClientUserIdTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@ -12,10 +12,12 @@
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
use Da\User\Traits\AuthClientUserIdTrait;
|
||||
use yii\authclient\clients\GitHub as BaseGitHub;
|
||||
|
||||
class GitHub extends BaseGitHub implements AuthClientInterface
|
||||
{
|
||||
use AuthClientUserIdTrait;
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@ -12,10 +12,12 @@
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
use Da\User\Traits\AuthClientUserIdTrait;
|
||||
use yii\authclient\clients\Google as BaseGoogle;
|
||||
|
||||
class Google extends BaseGoogle implements AuthClientInterface
|
||||
{
|
||||
use AuthClientUserIdTrait;
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@ -12,10 +12,13 @@
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
use Da\User\Traits\AuthClientUserIdTrait;
|
||||
use yii\authclient\clients\LinkedIn as BaseLinkedIn;
|
||||
|
||||
class LinkedIn extends BaseLinkedIn implements AuthClientInterface
|
||||
{
|
||||
use AuthClientUserIdTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@ -12,10 +12,13 @@
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
use Da\User\Traits\AuthClientUserIdTrait;
|
||||
use yii\authclient\clients\Twitter as BaseTwitter;
|
||||
|
||||
class Twitter extends BaseTwitter implements AuthClientInterface
|
||||
{
|
||||
use AuthClientUserIdTrait;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@ -12,11 +12,14 @@
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
use Da\User\Traits\AuthClientUserIdTrait;
|
||||
use Yii;
|
||||
use yii\authclient\clients\VKontakte as BaseVKontakte;
|
||||
|
||||
class VKontakte extends BaseVKontakte implements AuthClientInterface
|
||||
{
|
||||
use AuthClientUserIdTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@ -12,11 +12,14 @@
|
||||
namespace Da\User\AuthClient;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
use Da\User\Traits\AuthClientUserIdTrait;
|
||||
use Yii;
|
||||
use yii\authclient\clients\Yandex as BaseYandex;
|
||||
|
||||
class Yandex extends BaseYandex implements AuthClientInterface
|
||||
{
|
||||
use AuthClientUserIdTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
14
src/User/Traits/AuthClientUserIdTrait.php
Normal file
14
src/User/Traits/AuthClientUserIdTrait.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Traits;
|
||||
|
||||
trait AuthClientUserIdTrait
|
||||
{
|
||||
/**
|
||||
* @see \Da\User\Contracts\AuthClientInterface::getUserId()
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
return $this->getUserAttributes()['id'] ?? null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user