Example #1
0
 /**
  * Creates a URL according to the given route and parameters.
  * 
  * @param UrlManager $manager the URL manager
  * @param string $route the route. It should not have slashes at the beginning or the end.
  * @param array $params the parameters
  * @return string|boolean the created URL, or false if this rule cannot be used for creating this URL.
  */
 public function createUrl($manager, $route, $params)
 {
     if ($route === 'pages/page/show') {
         $category = Yii::$app->big->categoryManager->getItem($params['catid']);
         // a category must be selected when creating a page. The category could have been deleted though
         $menu = false;
         if ($category) {
             $route = Route::raw($category, Route::TYPE_CATEGORY);
             $menuManager = Yii::$app->big->menuManager;
             $menu = $menuManager->search('route', $route);
         }
         // check if a menu has been created for the page category
         // if so prepend the menu query to the created url
         // if not prepend the id of this url rule
         if ($menu) {
             $prepend = $menu->getQuery();
         } else {
             $prepend = $this->_id;
         }
         return $prepend . '/' . $params['alias'];
     } elseif ($route === 'pages/category/pages') {
         return $this->_categoryId . '/' . $params['catid'] . '/' . $params['alias'];
     }
     return false;
 }