public function parseRequest($manager, $request) { $pathInfo = $request->getPathInfo(); if (preg_match('%^([_\-A-Za-z0-9]+)(/([_\-A-Za-z0-9]+))?$%', $pathInfo, $matches)) { $page_categories = Categories::findOne(['slug' => $matches[1]]); if (!isset($matches[3])) { return [ 'site/index', ['categories_slug' => $page_categories->slug] ]; } $page_categories_item = CategoriesItem::findOne(['slug' => $matches[3]]); if ($page_categories_item) { return [ 'site/index', ['categories_slug' => $page_categories->slug, 'categories_item_slug' => $page_categories_item->slug] ];
if (preg_match('%^([_\-A-Za-z0-9]+)(/([_\-A-Za-z0-9]+))?$%', $pathInfo, $matches)) { $page_categories = Categories::findOne(['slug' => $matches[1]]); if (!isset($matches[3])) { return [ 'site/index', ['categories_slug' => $page_categories->slug] ]; } $page_categories_item = CategoriesItem::findOne(['slug' => $matches[3]]); if ($page_categories_item) { return [
*/ public function parseRequest($request) { if ($this->enablePrettyUrl) { /* @var $rule UrlRule */ foreach ($this->rules as $rule) { if (($result = $rule->parseRequest($this, $request)) !== false) { return $result; } } if ($this->enableStrictParsing) { return false;
* Resolves the current request into a route and the associated parameters. * @return array the first element is the route, and the second is the associated parameters. * @throws NotFoundHttpException if the request cannot be resolved. */ public function resolve() { $result = Yii::$app->getUrlManager()->parseRequest($this); if ($result !== false) { list ($route, $params) = $result; if ($this->_queryParams === null) { $_GET = $params + $_GET; // preserve numeric keys } else { $this->_queryParams = $params + $this->_queryParams;
* @throws NotFoundHttpException if the requested route is invalid */ public function handleRequest($request) { if (empty($this->catchAll)) { try { list ($route, $params) = $request->resolve(); } catch (UrlNormalizerRedirectException $e) { $url = $e->url; if (is_array($url)) { if (isset($url[0])) { // ensure the route is absolute $url[0] = '/' . ltrim($url[0], '/');
try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
require(__DIR__ . '/../../common/config/main.php'), require(__DIR__ . '/../../common/config/main-local.php'), require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main-local.php') ); (new yii\web\Application($config))->run();