Hello. I study the work of the urlmanager in yii2 and I can not figure out parseReequest, I created my own class
public function createUrl($manager, $route, $params) { if ($route === 'template/view') { if (isset($params['id'])) { $template = Template::findOne($params['id']); if (!empty($template)) { $slug = $template->slug; return 'template/'.$slug.'/view'; } } } elseif ($route === 'template/update') { if (isset($params['id'])) { $template = Template::findOne($params['id']); if (!empty($template)) { $slug = $template->slug; return 'template/'.$slug.'/update'; } } } } public function parseRequest ($manager, $request) { $pathInfo = $request->getPathInfo(); if (preg_match('%^template/(\w+)(?:/(\w+))$%', $pathInfo, $matches)) { $template = Template::findOne($params['id']); if (!empty($template)) { $params['id'] = $template->id; return ['template/' . $matches[1], $params]; } } return false; } I can not understand how to parse, that would automatically substitute action! how to do it right?
templatedo you have a module or controller? - Blacknife'template/'.$slug.'/update'- Blacknifetemplate/view?id=480ortemplate/update?id=480but received a view liketemplate/slug/viewortemplate/slug/updateare normal, the links are converted, and Here's how to parse and send I can not figure it out. parseRequest does not give in to me ((((.. - Roman