Class yii\authclient\Collection

Inheritanceyii\authclient\Collection » yii\base\Component
Available since version2.0

Collection is a storage for all auth clients in the application.

Example application configuration:

'components' => [
    'authClientCollection' => [
        'class' => 'yii\authclient\Collection',
        'clients' => [
            'google' => [
                'class' => 'yii\authclient\clients\Google',
                'clientId' => 'google_client_id',
                'clientSecret' => 'google_client_secret',
             ],
            'facebook' => [
                'class' => 'yii\authclient\clients\Facebook',
                'clientId' => 'facebook_client_id',
                'clientSecret' => 'facebook_client_secret',
            ],
        ],
    ]
    ...
]

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$httpClient \yii\httpclient\Client|array|string HTTP client instance or configuration for the \yii\authclient\clients. yii\authclient\Collection

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
createClient() Creates auth client instance from its array configuration. yii\authclient\Collection

Property Details

$httpClient public property

HTTP client instance or configuration for the \yii\authclient\clients. If set, this value will be passed as 'httpClient' config option while instantiating particular client object. This option is useful for adjusting HTTP client configuration for the entire list of auth clients.

public \yii\httpclient\Client|array|string $httpClient null

Method Details

createClient() protected method

Creates auth client instance from its array configuration.

protected yii\authclient\ClientInterface createClient ( $id, $config )
$id string

Auth client id.

$config array

Auth client instance configuration.

return yii\authclient\ClientInterface

Auth client instance.

getClient() public method

public yii\authclient\ClientInterface getClient ( $id )
$id string

Service id.

return yii\authclient\ClientInterface

Auth client instance.

throws \yii\base\InvalidParamException

on non existing client request.

getClients() public method

public yii\authclient\ClientInterface[] getClients ( )
return yii\authclient\ClientInterface[]

List of auth clients.

hasClient() public method

Checks if client exists in the hub.

public boolean hasClient ( $id )
$id string

Client id.

return boolean

Whether client exist.

setClients() public method

public void setClients ( array $clients )
$clients array

List of auth clients