public function createUrl($manager, $route, $params)
{
if ($route === 'serial/category/oneserial') {
if (isset($params['id'])) {
return 'serials/'.$params['id'];
}
}elseif($route === 'serial/category/list'){
if (isset($params['slug'])) {
return 'serials/'.$params['slug'];
}
}
return false; // данное правило не применимо
}
public function parseRequest($manager, $request)
{
$pathInfo = $request->getPathInfo();
if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches)) {
$path=$matches[0];
if($path=='serial/category/oneserial'){
$exists = Serial::find()->where(['slug_serial' => $matches[1]])->exists();
if($exists){
return ['serial/category/oneserial','id'=>$matches[1]];
}
}
if($path=='serial/category/list'){
$exists = Category::find()->where(['slug_category' => $matches[1]])->exists();
if($exists){
return ['serial/category/list','slug'=>$matches[1]];
}
}
}
return false; // данное правило не применимо
}