Example #1
0
 public function generateSaltUrl($request)
 {
     $_url = ltrim(parse_url($request->getUrl(), PHP_URL_PATH), '/');
     $_params = $request->get();
     if ($this->redirect301 == true) {
         $route = \dlds\urlias\models\UrlRule::getRoute($_url, $_params);
         if (!is_null($route) && $route->redirect) {
             Yii::$app->response->redirect([$route->slug], 301);
         }
     }
     return $_url;
 }
Example #2
0
 public function _setAlias($slug, $config)
 {
     $route = $this->_getRoute($config);
     $params = $this->_getParams($config);
     $rule = \dlds\urlias\models\UrlRule::getRoute($route, $params);
     if (!$rule) {
         $rule = new \dlds\urlias\models\UrlRule();
         $rule->route = $route;
         $rule->params = serialize($params);
     }
     $rule->slug = $slug;
     $rule->redirect = 0;
     $rule->status = 1;
     if ($rule->save()) {
         \dlds\urlias\components\BaseUrlRule::removeCache($route, $params);
     }
 }