Exemplo n.º 1
0
 /**
  * @param ActiveRecord $object
  *
  * @return string
  */
 public static function niceUrlTo(ActiveRecord $object)
 {
     /** @var Language $language */
     $language = Language::findOne(['symbol' => \Yii::$app->language]);
     /** @var NiceUrl $niceUrl */
     $niceUrl = NiceUrl::findOne(['object_class' => get_class($object), 'object_id' => $object->id, 'language_id' => $language->id, 'redirect' => 0]);
     return sprintf('%s', $niceUrl->url);
 }
Exemplo n.º 2
0
 /**
  * @param NiceUrl $niceUrl
  */
 public static function dropOldNiceUrl(NiceUrl $niceUrl)
 {
     /** @var NiceUrl $oldNiceUrl */
     $oldNiceUrl = NiceUrl::findOne(['object_class' => $niceUrl->object_class, 'object_id' => $niceUrl->object_id, 'language_id' => $niceUrl->language_id, 'redirect' => false]);
     if (is_null($oldNiceUrl) == false) {
         $oldNiceUrl->redirect = true;
         $oldNiceUrl->save();
     }
 }