Answer the question
In order to leave comments, you need to log in
How to change the format of generated links using Url::to in Yii2?
I do sending mail at registration.
The site works like this: the frontend is in angular, that is, Ajax, and the backend is Yii2.
Here is the method code:
public function getUrl()
{
switch ($this->type) {
case self::TYPE_CONFIRMATION:
$route = '/#/api/registration/confirm';
break;
case self::TYPE_RECOVERY:
$route = '/#/api/recovery/reset';
break;
case self::TYPE_CONFIRM_NEW_EMAIL:
case self::TYPE_CONFIRM_OLD_EMAIL:
$route = '/#/api/settings/confirm';
break;
default:
throw new \RuntimeException;
}
return Url::to([$route, 'id' => $this->user_id, 'code' => $this->code], true);
}
Answer the question
In order to leave comments, you need to log in
"The site is in angular, that is, ajax" - what does yii have to do with it? Did you blind them? Angular frontend, YII backend?
"Based on what law did Yii build a URL to a friend?" - dig urlmanager in config and read manuals www.yiiframework.com/doc-2.0/yii-helpers-url.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question