public static function getCanonical()
{
$firstTable = Registry::get('firstTable');
$secondTable = Registry::get('secondTable');
$lastTable = Registry::get('lastTable');
$firstParameter = Registry::get('firstParameter');
$secondParameter = Registry::get('secondParameter');
$categoryParameter = $secondTable === 'categories' ? $secondParameter : $firstParameter;
$fullRoute = Registry::get('fullRoute');
/* find route */
if ($firstTable === 'categories' && $lastTable === 'articles') {
$categoryId = Db::forTablePrefix($firstTable)->where('alias', $categoryParameter)->findOne()->id;
$articlesTotal = Db::forTablePrefix('articles')->where('category', $categoryId)->count();
if ($articlesTotal === 1) {
$route = $firstParameter;
if ($secondTable === 'categories') {
$route .= '/' . $secondParameter;
}
}
}
/* handle route */
if ($route) {
return Registry::get('parameterRoute') . $route;
}
return $fullRoute;
}