当前位置: 首页>>代码示例>>PHP>>正文


PHP ClientInterface::getViewOptions方法代码示例

本文整理汇总了PHP中yii\authclient\ClientInterface::getViewOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::getViewOptions方法的具体用法?PHP ClientInterface::getViewOptions怎么用?PHP ClientInterface::getViewOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\authclient\ClientInterface的用法示例。


在下文中一共展示了ClientInterface::getViewOptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: clientLink

 /**
  * Добавляем обрамление div
  * @param ClientInterface $client
  * @param null $text
  * @param array $htmlOptions
  * @throws InvalidConfigException
  */
 public function clientLink($client, $text = null, array $htmlOptions = [])
 {
     echo Html::beginTag('div', ['class' => $this->clientCssClass]);
     $text = Html::tag('span', $text, ['class' => 'auth-icon ' . $client->getName()]);
     if (!array_key_exists('class', $htmlOptions)) {
         $htmlOptions['class'] = 'auth-link ' . $client->getName();
     }
     $viewOptions = $client->getViewOptions();
     if (empty($viewOptions['widget'])) {
         if ($this->popupMode) {
             if (isset($viewOptions['popupWidth'])) {
                 $htmlOptions['data-popup-width'] = $viewOptions['popupWidth'];
             }
             if (isset($viewOptions['popupHeight'])) {
                 $htmlOptions['data-popup-height'] = $viewOptions['popupHeight'];
             }
         }
         echo Html::a($text, $this->createClientUrl($client), $htmlOptions) . '<br>';
     } else {
         $widgetConfig = $viewOptions['widget'];
         if (!isset($widgetConfig['class'])) {
             throw new InvalidConfigException('Widget config "class" parameter is missing');
         }
         /* @var $widgetClass Widget */
         $widgetClass = $widgetConfig['class'];
         if (!is_subclass_of($widgetClass, AuthChoiceItem::className())) {
             throw new InvalidConfigException('Item widget class must be subclass of "' . AuthChoiceItem::className() . '"');
         }
         unset($widgetConfig['class']);
         $widgetConfig['client'] = $client;
         $widgetConfig['authChoice'] = $this;
         echo $widgetClass::widget($widgetConfig);
     }
     echo Html::endTag('div');
 }
开发者ID:lowbase,项目名称:yii2-user,代码行数:42,代码来源:AuthChoice.php

示例2: clientLink

 /**
  * Меняем ссылки на добавление и удаление ключей
  * @param ClientInterface $client external auth client instance.
  * @param string $text link text, if not set - default value will be generated.
  * @param array $htmlOptions link HTML options.
  * @throws InvalidConfigException on wrong configuration.
  */
 public function clientLink($client, $text = null, array $htmlOptions = [])
 {
     echo Html::beginTag('div', ['class' => 'col-xs-4']);
     $exists = UserOauthKey::findOne(['user_id' => Yii::$app->user->id, 'provider_id' => UserOauthKey::getAvailableClients()[$client->getId()]]);
     if ($exists) {
         $button = Html::a('<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> <span class="hidden-xs">' . Yii::t('user', 'Удалить') . '</span>', Url::toRoute(['auth/unbind', 'id' => $client->getId()]), ['class' => 'btn btn-danger btn-sm', 'onclick' => '$(this).off("click"); return true;']);
     } else {
         $viewOptions = $client->getViewOptions();
         if (isset($viewOptions['popupWidth'])) {
             $htmlOptions['data-popup-width'] = $viewOptions['popupWidth'];
         }
         if (isset($viewOptions['popupHeight'])) {
             $htmlOptions['data-popup-height'] = $viewOptions['popupHeight'];
         }
         $htmlOptions['class'] = 'btn btn-success btn-sm';
         $button = Html::a('<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> <span class="hidden-xs">' . Yii::t('user', 'Добавить') . '</span>', $this->createClientUrl($client), $htmlOptions);
     }
     echo Html::tag('span', $button, ['class' => 'auth-icon ' . $client->getName(), 'style' => 'padding-left: 40px; margin-bottom: 10px;']);
     echo Html::endTag('div');
 }
开发者ID:lowbase,项目名称:yii2-user,代码行数:27,代码来源:AuthKeysManager.php

示例3: clientLink

 /**
  * Outputs client auth link.
  * @param ClientInterface $client external auth client instance.
  * @param string $text link text, if not set - default value will be generated.
  * @param array $htmlOptions link HTML options.
  * @return string generated HTML.
  * @throws InvalidConfigException on wrong configuration.
  */
 public function clientLink($client, $text = null, array $htmlOptions = [])
 {
     $viewOptions = $client->getViewOptions();
     if (empty($viewOptions['widget'])) {
         if ($text === null) {
             $text = Html::tag('span', '', ['class' => 'auth-icon ' . $client->getName()]);
         }
         if (!isset($htmlOptions['class'])) {
             $htmlOptions['class'] = $client->getName();
         }
         if (!isset($htmlOptions['title'])) {
             $htmlOptions['title'] = $client->getTitle();
         }
         Html::addCssClass($htmlOptions, ['widget' => 'auth-link']);
         if ($this->popupMode) {
             if (isset($viewOptions['popupWidth'])) {
                 $htmlOptions['data-popup-width'] = $viewOptions['popupWidth'];
             }
             if (isset($viewOptions['popupHeight'])) {
                 $htmlOptions['data-popup-height'] = $viewOptions['popupHeight'];
             }
         }
         return Html::a($text, $this->createClientUrl($client), $htmlOptions);
     }
     $widgetConfig = $viewOptions['widget'];
     if (!isset($widgetConfig['class'])) {
         throw new InvalidConfigException('Widget config "class" parameter is missing');
     }
     /* @var $widgetClass Widget */
     $widgetClass = $widgetConfig['class'];
     if (!is_subclass_of($widgetClass, AuthChoiceItem::className())) {
         throw new InvalidConfigException('Item widget class must be subclass of "' . AuthChoiceItem::className() . '"');
     }
     unset($widgetConfig['class']);
     $widgetConfig['client'] = $client;
     $widgetConfig['authChoice'] = $this;
     return $widgetClass::widget($widgetConfig);
 }
开发者ID:yiisoft,项目名称:yii2-authclient,代码行数:46,代码来源:AuthChoice.php

示例4: clientLink

 /**
  * Outputs client auth link.
  * @param ClientInterface $client external auth client instance.
  * @param string $text link text, if not set - default value will be generated.
  * @param array $htmlOptions link HTML options.
  */
 public function clientLink($client, $text = null, array $htmlOptions = [])
 {
     if ($text === null) {
         $text = Html::tag('span', '', ['class' => 'auth-icon ' . $client->getName()]);
         $text .= Html::tag('span', $client->getTitle(), ['class' => 'auth-title']);
     }
     if (!array_key_exists('class', $htmlOptions)) {
         $htmlOptions['class'] = 'auth-link ' . $client->getName();
     }
     if ($this->popupMode) {
         $viewOptions = $client->getViewOptions();
         if (isset($viewOptions['popupWidth'])) {
             $htmlOptions['data-popup-width'] = $viewOptions['popupWidth'];
         }
         if (isset($viewOptions['popupHeight'])) {
             $htmlOptions['data-popup-height'] = $viewOptions['popupHeight'];
         }
     }
     echo Html::a($text, $this->createClientUrl($client), $htmlOptions);
 }
开发者ID:cakpep,项目名称:spk-tht,代码行数:26,代码来源:AuthChoice.php


注:本文中的yii\authclient\ClientInterface::getViewOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。