forked from yiisoft/yii2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yii\authclient\AuthChoiceItem
extracted
- Loading branch information
1 parent
b199a71
commit 4c26906
Showing
3 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* @link http://www.yiiframework.com/ | ||
* @copyright Copyright (c) 2008 Yii Software LLC | ||
* @license http://www.yiiframework.com/license/ | ||
*/ | ||
|
||
namespace yii\authclient\widgets; | ||
|
||
use yii\base\Widget; | ||
|
||
/** | ||
* AuthChoiceItem is a base class for creating widgets, which can be used to render link | ||
* for auth client at [[AuthChoice]]. | ||
* | ||
* @see AuthChoice | ||
* | ||
* @author Paul Klimov <[email protected]> | ||
* @since 2.0 | ||
*/ | ||
class AuthChoiceItem extends Widget | ||
{ | ||
/** | ||
* @var \yii\authclient\ClientInterface auth client instance. | ||
*/ | ||
public $client; | ||
/** | ||
* @var AuthChoice parent AuthChoice widget | ||
*/ | ||
public $authChoice; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
|
||
use yii\authclient\clients\GooglePlus; | ||
use yii\base\InvalidConfigException; | ||
use yii\base\Widget; | ||
use yii\helpers\Html; | ||
use yii\helpers\Url; | ||
use yii\web\View; | ||
|
@@ -21,17 +20,14 @@ | |
* @see GooglePlus | ||
* @see https://developers.google.com/+/web/signin/ | ||
* | ||
* @property \yii\authclient\clients\GooglePlus $client auth client instance. | ||
* @property string|array $callback | ||
* | ||
* @author Paul Klimov <[email protected]> | ||
* @since 2.0 | ||
*/ | ||
class GooglePlusButton extends Widget | ||
class GooglePlusButton extends AuthChoiceItem | ||
{ | ||
/** | ||
* @var GooglePlus google auth client instance. | ||
*/ | ||
public $client; | ||
/** | ||
* @var array button tag HTML options, which will be merged with the default ones. | ||
*/ | ||
|
@@ -94,9 +90,10 @@ public function run() | |
protected function generateCallback($url = []) | ||
{ | ||
if (empty($url)) { | ||
$url = ['auth', 'authclient' => $this->client->id]; | ||
$url = $this->authChoice->createClientUrl($this->client); | ||
} else { | ||
$url = Url::to($url); | ||
} | ||
$url = Url::to($url); | ||
if (strpos($url, '?') === false) { | ||
$url .= '?'; | ||
} else { | ||
|