Решил через UrlRule
class ProfileUrlRule implements UrlRuleInterface
{
public function createUrl($manager, $route, $params)
{
if (preg_match('/^staff\//', $route)) {
return str_replace('staff/', '', $route);
}
if (preg_match('/^customer\//', $route)) {
return str_replace('customer/', '', $route);
}
return false;
}
public function parseRequest($manager, $request)
{
$pathInfo = trim($request->pathInfo, '/');
$pathInfo = explode('/', $pathInfo);
if (is_array($pathInfo) && $pathInfo[0] == 'profile' &&
in_array(Yii::$app->user->identity->type, [UserHelper::TYPE_CUSTOMER, UserHelper::TYPE_STAFF])
) {
if (Yii::$app->user->identity->type == UserHelper::TYPE_STAFF) {
return [str_replace('profile', 'staff/profile', $request->pathInfo), []];
} elseif (Yii::$app->user->identity->type == UserHelper::TYPE_CUSTOMER) {
return [str_replace('profile', 'customer/profile', $request->pathInfo), []];
}
}
return false;
}
}