Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
52de0405
Commit
52de0405
authored
Dec 25, 2013
by
Paul Klimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Auth clients "Choice" doc comments updated.
parent
6b374529
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
9 deletions
+32
-9
Choice.php
extensions/yii/authclient/widgets/Choice.php
+31
-8
ChoiceAsset.php
extensions/yii/authclient/widgets/ChoiceAsset.php
+1
-1
No files found.
extensions/yii/authclient/widgets/Choice.php
View file @
52de0405
...
@@ -13,7 +13,30 @@ use yii\helpers\Html;
...
@@ -13,7 +13,30 @@ use yii\helpers\Html;
use
yii\authclient\ClientInterface
;
use
yii\authclient\ClientInterface
;
/**
/**
* Class Choice
* Choice prints buttons for authentication via various auth clients.
* By default this widget relies on presence of [[\yii\authclient\Collection]] among application components
* to get auth clients information.
*
* Example:
* ~~~
* <?= yii\authclient\Choice::widget([
* 'baseAuthUrl' => ['site/auth']
* ]); ?>
* ~~~
*
* You can customize the widget appearance by using [[beginWidget()]] and [[endWidget()]] syntax
* along with using method {@link clientLink()} or {@link createClientUrl()}.
* For example:
*
* ~~~
* <?php $authChoice = yii\authclient\Choice::beginWidget(); ?>
* <ul>
* <?php foreach ($authChoice->getClients() as $client): ?>
* <li><?= $authChoice->clientLink($client); ?></li>
* <?php endforeach; ?>
* </ul>
* <?php yii\authclient\Choice::endWidget(); ?>
* ~~~
*
*
* @property ClientInterface[] $providers auth providers list.
* @property ClientInterface[] $providers auth providers list.
* @property array $baseAuthUrl configuration for the external services base authentication URL.
* @property array $baseAuthUrl configuration for the external services base authentication URL.
...
@@ -122,12 +145,12 @@ class Choice extends Widget
...
@@ -122,12 +145,12 @@ class Choice extends Widget
}
}
/**
/**
* Outputs
external service
auth link.
* Outputs
client
auth link.
* @param ClientInterface $client external auth client instance.
* @param ClientInterface $client external auth client instance.
* @param string $text link text, if not set - default value will be generated.
* @param string $text link text, if not set - default value will be generated.
* @param array $htmlOptions link HTML options.
* @param array $htmlOptions link HTML options.
*/
*/
public
function
provider
Link
(
$client
,
$text
=
null
,
array
$htmlOptions
=
[])
public
function
client
Link
(
$client
,
$text
=
null
,
array
$htmlOptions
=
[])
{
{
if
(
$text
===
null
)
{
if
(
$text
===
null
)
{
$text
=
Html
::
tag
(
'span'
,
''
,
[
'class'
=>
'auth-icon '
.
$client
->
getName
()]);
$text
=
Html
::
tag
(
'span'
,
''
,
[
'class'
=>
'auth-icon '
.
$client
->
getName
()]);
...
@@ -145,15 +168,15 @@ class Choice extends Widget
...
@@ -145,15 +168,15 @@ class Choice extends Widget
$htmlOptions
[
'data-popup-height'
]
=
$viewOptions
[
'popupHeight'
];
$htmlOptions
[
'data-popup-height'
]
=
$viewOptions
[
'popupHeight'
];
}
}
}
}
echo
Html
::
a
(
$text
,
$this
->
create
Provider
Url
(
$client
),
$htmlOptions
);
echo
Html
::
a
(
$text
,
$this
->
create
Client
Url
(
$client
),
$htmlOptions
);
}
}
/**
/**
* Composes
external service
auth URL.
* Composes
client
auth URL.
* @param ClientInterface $provider external auth
service
instance.
* @param ClientInterface $provider external auth
client
instance.
* @return string auth URL.
* @return string auth URL.
*/
*/
public
function
create
Provider
Url
(
$provider
)
public
function
create
Client
Url
(
$provider
)
{
{
$this
->
autoRender
=
false
;
$this
->
autoRender
=
false
;
$url
=
$this
->
getBaseAuthUrl
();
$url
=
$this
->
getBaseAuthUrl
();
...
@@ -169,7 +192,7 @@ class Choice extends Widget
...
@@ -169,7 +192,7 @@ class Choice extends Widget
echo
Html
::
beginTag
(
'ul'
,
[
'class'
=>
'auth-clients clear'
]);
echo
Html
::
beginTag
(
'ul'
,
[
'class'
=>
'auth-clients clear'
]);
foreach
(
$this
->
getClients
()
as
$externalService
)
{
foreach
(
$this
->
getClients
()
as
$externalService
)
{
echo
Html
::
beginTag
(
'li'
,
[
'class'
=>
'auth-client'
]);
echo
Html
::
beginTag
(
'li'
,
[
'class'
=>
'auth-client'
]);
$this
->
provider
Link
(
$externalService
);
$this
->
client
Link
(
$externalService
);
echo
Html
::
endTag
(
'li'
);
echo
Html
::
endTag
(
'li'
);
}
}
echo
Html
::
endTag
(
'ul'
);
echo
Html
::
endTag
(
'ul'
);
...
...
extensions/yii/authclient/widgets/ChoiceAsset.php
View file @
52de0405
...
@@ -10,7 +10,7 @@ namespace yii\authclient\widgets;
...
@@ -10,7 +10,7 @@ namespace yii\authclient\widgets;
use
yii\web\AssetBundle
;
use
yii\web\AssetBundle
;
/**
/**
* C
lass ChoiceAsset
* C
hoiceAsset is an asset bundle for [[Choice]] widget.
*
*
* @author Paul Klimov <klimov.paul@gmail.com>
* @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0
* @since 2.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment