/**
  * Renders the main content, which includes all external services links.
  */
 protected function renderMainContent()
 {
     echo Html::beginTag('div', ['class' => 'social-login']);
     foreach ($this->getClients() as $externalService) {
         $socialServiceId = SocialService::classNameToId(get_class($externalService));
         $i18n = SocialService::i18nNameById($socialServiceId);
         $this->clientLink($externalService, '<i class="demo-icon icon-basic-' . $externalService->getName() . '"></i>', ['class' => "social-login__social-network social-login__social-network--" . $externalService->getName(), 'title' => $i18n]);
     }
     echo Html::endTag('ul');
 }
Beispiel #2
0
 protected function authSuccess($client)
 {
     /** @var \yii\authclient\BaseClient $client */
     $this->socialServiceId = SocialService::classNameToId($client->className());
     if ($this->socialServiceId === 0) {
         throw new ServerErrorHttpException("SocialService unknown");
     }
     // first find user service on this id
     $userAttributes = $client->getUserAttributes();
     $this->serviceId = $userAttributes['id'];
     //! @todo Add caching here based on commonTag
     $this->userService = UserService::find()->where(['service_id' => $this->serviceId, 'social_service_id' => $this->socialServiceId])->one();
     return parent::authSuccess($client);
 }
 /**
  * Runs the widget.
  */
 public function run()
 {
     if ($this->autoRender) {
         $this->renderMainContent();
     }
     echo Html::endTag('div');
     echo Html::beginTag('div', ['class' => 'social-delete']);
     echo Html::tag('h2', Yii::t('users', 'Delete social service'));
     foreach ($this->getClients() as $externalService) {
         if (in_array(get_class($externalService), array_keys($this->services))) {
             $socialServiceId = SocialService::classNameToId(get_class($externalService));
             $i18n = SocialService::i18nNameById($socialServiceId);
             echo Html::a('<i class="demo-icon icon-basic-' . $externalService->getName() . '"></i>', ['@delete-social', 'service_id' => $socialServiceId], ['class' => "social-login__social-network social-login__social-network--" . $externalService->getName(), 'title' => $i18n]);
         }
     }
     echo Html::endTag('ul');
     echo Html::endTag('div');
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSocialService()
 {
     return $this->hasOne(SocialService::className(), ['id' => 'social_service_id']);
 }