• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Jaxel's Method for Creating A Route Controller

Jaxel's Method for Creating A Route Controller

Jaxel

Well-known member
#1

Jaxel

Well-known member
#5
I realize now though that the guide I put together only works if your data actions have integers in them. If you're doing PURE string data, you may have issues. I came into this issue with my XenMedio mod; almost all the data types use number IDs... except for keyword pages. Keyword pages use string data only... I managed a workaround using the following as my match:

Code:
public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
{
    $action = $router->resolveActionWithIntegerParam($routePath, $request, 'action_id');
    $action = $router->resolveActionAsPageNumber($action, $request);
   
    $actions = explode('/', $action);
   
    switch ($actions[0])
    {
        case 'admin':            $controller = '_Admin';                break;
        case 'category':        $controller = '_Category';            break;
        case 'comment':            $controller = '_Comment';            break;
        case 'keyword':            $controller = '_Keyword';            break;
        case 'media':            $controller = '_Media';                break;
        case 'playlist':        $controller = '_Playlist';            break;
        case 'user':            $controller = '_User';                break;
        case 'service':            $controller = '_Service';            break;
        default:                $controller = '';
    }
   
    if (!empty($actions[1]) && $actions[1] == 'keyword')
    {
        $controller = '_Keyword';
        $action = $router->resolveActionWithStringParam($routePath, $request, 'string_id');
    }
   
    return $router->getRouteMatch('EWRmedio_ControllerPublic_Media'.$controller, $action, 'media');
}