Ejemplo 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);
 }
Ejemplo 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();
     }
 }
Ejemplo n.º 3
0
 /**
  * @param Event $event
  */
 public function deleteNiceUrl(Event $event)
 {
     /** @var Page $page */
     $page = $event->sender;
     NiceUrl::deleteAll(['object_class' => Page::className(), 'object_id' => $page->id]);
 }