Add trait to support new interface in a backward compatible way
This commit is contained in:
@ -12,10 +12,14 @@
|
|||||||
namespace Da\User\AuthClient;
|
namespace Da\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use Da\User\Contracts\AuthClientInterface;
|
||||||
|
use Da\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\clients\Facebook as BaseFacebook;
|
use yii\authclient\clients\Facebook as BaseFacebook;
|
||||||
|
|
||||||
class Facebook extends BaseFacebook implements AuthClientInterface
|
class Facebook extends BaseFacebook implements AuthClientInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
use AuthClientUserIdTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -12,10 +12,12 @@
|
|||||||
namespace Da\User\AuthClient;
|
namespace Da\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use Da\User\Contracts\AuthClientInterface;
|
||||||
|
use Da\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\clients\GitHub as BaseGitHub;
|
use yii\authclient\clients\GitHub as BaseGitHub;
|
||||||
|
|
||||||
class GitHub extends BaseGitHub implements AuthClientInterface
|
class GitHub extends BaseGitHub implements AuthClientInterface
|
||||||
{
|
{
|
||||||
|
use AuthClientUserIdTrait;
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -12,10 +12,12 @@
|
|||||||
namespace Da\User\AuthClient;
|
namespace Da\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use Da\User\Contracts\AuthClientInterface;
|
||||||
|
use Da\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\clients\Google as BaseGoogle;
|
use yii\authclient\clients\Google as BaseGoogle;
|
||||||
|
|
||||||
class Google extends BaseGoogle implements AuthClientInterface
|
class Google extends BaseGoogle implements AuthClientInterface
|
||||||
{
|
{
|
||||||
|
use AuthClientUserIdTrait;
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -12,10 +12,13 @@
|
|||||||
namespace Da\User\AuthClient;
|
namespace Da\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use Da\User\Contracts\AuthClientInterface;
|
||||||
|
use Da\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\clients\LinkedIn as BaseLinkedIn;
|
use yii\authclient\clients\LinkedIn as BaseLinkedIn;
|
||||||
|
|
||||||
class LinkedIn extends BaseLinkedIn implements AuthClientInterface
|
class LinkedIn extends BaseLinkedIn implements AuthClientInterface
|
||||||
{
|
{
|
||||||
|
use AuthClientUserIdTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -12,10 +12,13 @@
|
|||||||
namespace Da\User\AuthClient;
|
namespace Da\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use Da\User\Contracts\AuthClientInterface;
|
||||||
|
use Da\User\Traits\AuthClientUserIdTrait;
|
||||||
use yii\authclient\clients\Twitter as BaseTwitter;
|
use yii\authclient\clients\Twitter as BaseTwitter;
|
||||||
|
|
||||||
class Twitter extends BaseTwitter implements AuthClientInterface
|
class Twitter extends BaseTwitter implements AuthClientInterface
|
||||||
{
|
{
|
||||||
|
use AuthClientUserIdTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -12,11 +12,14 @@
|
|||||||
namespace Da\User\AuthClient;
|
namespace Da\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use Da\User\Contracts\AuthClientInterface;
|
||||||
|
use Da\User\Traits\AuthClientUserIdTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\authclient\clients\VKontakte as BaseVKontakte;
|
use yii\authclient\clients\VKontakte as BaseVKontakte;
|
||||||
|
|
||||||
class VKontakte extends BaseVKontakte implements AuthClientInterface
|
class VKontakte extends BaseVKontakte implements AuthClientInterface
|
||||||
{
|
{
|
||||||
|
use AuthClientUserIdTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -12,11 +12,14 @@
|
|||||||
namespace Da\User\AuthClient;
|
namespace Da\User\AuthClient;
|
||||||
|
|
||||||
use Da\User\Contracts\AuthClientInterface;
|
use Da\User\Contracts\AuthClientInterface;
|
||||||
|
use Da\User\Traits\AuthClientUserIdTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\authclient\clients\Yandex as BaseYandex;
|
use yii\authclient\clients\Yandex as BaseYandex;
|
||||||
|
|
||||||
class Yandex extends BaseYandex implements AuthClientInterface
|
class Yandex extends BaseYandex implements AuthClientInterface
|
||||||
{
|
{
|
||||||
|
use AuthClientUserIdTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@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