XF 2.0 Understanding basic routing

S Thomas

Well-known member
I've read https://xenforo.com/xf2-docs/dev/routing-basics/ but can't quite figure out what I'm missing. I've set up a test controller, it shows up fine, but the ParameterBag doesn't get populated.
Controller:
PHP:
<?php

namespace Test\TestAddon\Pub\Controller;
use XF\Mvc\ParameterBag;

class TestController extends \XF\Pub\Controller\AbstractController
{

     public function actionIndex(ParameterBag $params) {

        $this->setResponseType('json');
        $viewParams = [
            'params' => $params,
        ];
        return $this->view('Test\TestAddon:Test\TestView', '', $viewParams);
    }
}
View:
PHP:
<?php

namespace Test\TestAddon\Pub\View\Test;
use XF\Mvc\View;

class TestView extends View
{
    public function renderJson()
    {
        return [
            'params' => $this->params['params']
        ];
    }
}
Route:
o38mctk6.png

Result:
JSON:
{"params":{},"visitor":{"conversations_unread":"0","alerts_unread":"0","total_unread":"0"},"debug":{"time":0.0428,"queries":4,"memory":5.05}}
URL:
/test/1

$this->filter("test_id", "uint") also results in 0.

Would appreciate any help into the right direction.
 
Top Bottom