public function parseRequest($manager, $request)
{
$pathInfo = $request->getPathInfo();
if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches)) {
// check $matches[1] and $matches[3] to see
// if they match a manufacturer and a model in the database
// If so, set $params['manufacturer'] and/or $params['model']
// and return ['car/index', $params]
}
return false; // this rule does not apply
}
I dont know preg_match and need help with
'%^(\w+)(/(\w+))?$%
this part…
Function create url is set to create category/$row[‘url’] and i need to create parseRequest for this…
The default regexp for default action column url is generated based on the model class name. (generally folks keep the base part of controller and model naming similar when generating CRUD - so this tends to work by default). You can override this with whatever you need using the urlCreator property in ActionColumn.
But I think your query is not exactly related to this? Can you confirm?
class CategoryUrlRule extends UrlRule
{
public $connectionID = 'db';
public function createUrl($manager, $route, $params)
{
if ($route === 'category/view') {
if (isset($params['id'])) {
/** Find $row with that id and get category url ... */
return 'category' . '/' . $row['url'];
}
}
return false; // this rule does not apply
}
public function parseRequest($manager, $request)
{
$pathInfo = $request->getPathInfo();
if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches)) {
/** MISSING CODE + BAD PATTERN **/
// check $matches[1] and $matches[3] to see
// if they match a manufacturer and a model in the database
// If so, set $params['manufacturer'] and/or $params['model']
// and return ['car/index', $params]
}
return false; // this rule does not apply
}
}
And i don’t know how to write pattern for parsing request… I need just a simple example