Помогите решить проблему.
как передать данные из компонента в вид?
Код: Выделить всё
<?php
namespace app\components;
use app\models\Auth;
use app\models\User;
use Yii;
use yii\authclient\ClientInterface;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\web\Controller;
/**
* AuthHandler handles successful authentication via Yii auth component
*/
class AuthHandler
{
/**
* @var ClientInterface
*/
private $client;
public function __construct(ClientInterface $client)
{
$this->client = $client;
}
public function handle()
{
/*Sign in*/
$attributes = $this->client->getUserAttributes();
//debug($attributes); die();
if (ArrayHelper::getValue($attributes, 'email') && ArrayHelper::getValue($attributes, 'email') != "")
{
$email = ArrayHelper::getValue($attributes, 'email');
$id = ArrayHelper::getValue($attributes, 'id');
$nickname = ArrayHelper::getValue($attributes, 'name');
Yii::$app->getResponse()->redirect('sign', compact('email, nickname, id'));
return $this->redirect('sign', compact('email, nickname, id'));
}
elseif (!ArrayHelper::getValue($attributes, 'email') || ArrayHelper::getValue($attributes, 'email') != "")
{
//debug($email); die();
$id = ArrayHelper::getValue($attributes, 'id');
if(ArrayHelper::getValue($attributes, 'name') && ArrayHelper::getValue($attributes, 'name') !="")
{
//$id = ArrayHelper::getValue($attributes, 'id');
$nickname = ArrayHelper::getValue($attributes, 'name');
$email = "";
}
else
{
//$id = ArrayHelper::getValue($attributes, 'id');
$nickname = ArrayHelper::getValue($attributes, 'first_name');
$email = "";
}
//$nickname = ArrayHelper::getValue($attributes, 'name');
Yii::$app->getResponse()->redirect('sign', ['email' => $email, 'nickname' => $nickname, 'id' => $id]);
return $this->redirect('sign', compact('email, nickname, id'));
}