/** * * @param string $adress * @return string */ private function generateUrl(string $adress) : string { if (filter_var($adress, FILTER_VALIDATE_URL)) { return $adress; } else { $adress = json_decode(str_replace('|', '"', $adress), true); return $this->url->url($adress['route'], $adress['tokens']); } }
/** * * @param string $arg * @param int $parentId * @return string */ public function getCategoryList(string $arg, int $parentId = 1) : string { $string = "<ul {$arg}>"; if (array_key_exists(0, $this->categoryList)) { $string .= "<li><a href=\"{$this->url->url('default')}\">"; $string .= "{$this->categoryList[0]->getTitle()}</a>"; $string .= "</li>"; } $categoriesExists = count($this->categoryList); unset($this->categoryList[0]); foreach ($this->categoryList as $cat) { if ($parentId === $cat->getParentId()) { $url = $this->url->url('category-alias', ['alias' => $cat->getAlias()]); $string .= "<li><a href=\"{$url}\">"; $string .= "{$cat->getTitle()}</a>"; $string .= $this->getCategoryList($arg, $cat->getId()); $string .= "</li>"; } } $string .= "</ul>"; return $categoriesExists ? $string : ""; }
// provides current request and http method // $baseQuery argument defines folder via site is avilable: // http://fullSite.com/Adress => $baseQuery = /Adress (without slash on end) // It is possible to define custom request and http method: // $matcher->match(null, '/customRequest', 'GET'); // Display response // Display matched params echo 'Routes:<pre>'; print_r($response->all()); echo '</pre>'; // Get concrete param echo $response->get('token'); // Get route name echo 'Route name: '; echo $response->name(); echo '<br />'; // Get route group echo 'Route group: '; echo $response->group(); echo '<br />'; // Get route controller echo 'Controller: '; echo $response->controller(); echo '<br />'; // Get attachment $attachment = $response->attachment(); $attachment(); // Reverse Routing $url = new UrlGenerator($route, $host); echo 'Link: '; echo $url->url('user', ['user' => 'UserName']);