XF 2.2 Help routing to XFCP extension

CStrategies

Member
I get most things in XenForo but routes drive me mad.

I have added a custom action method to my extension of the XFRM resourceitem public controller.

Here is the format of the extension:
Code:
<?php

namespace My\Addon\XFRM\Pub\Controller;

use XF\Mvc\ParameterBag;
use XF\Pub\Controller\AbstractController;

class ResourceItem extends XFCP_ResourceItem
{
    public function actionMyAction(ParameterBag $params) {
}
}

I know the extension works, because I have other methods I already use in that extension.

Here is how I tried to set up my route in ACP:

Code:
Route type: Public
Route Prefix: resources
Sub-name: my-action
Route Format: my-action/:int<resource_id,title>/
Controller: My\Addon\XFRM:ResourceItem 
Action Prefix: myaction
Add-on: My Addon

I've also tried simply:

Code:
Route type: Public
Route Prefix: my-action
Controller: My\Addon\XFRM:ResourceItem 
Action Prefix: myaction
Add-on: My Addon


I always get the same error:
Code:
Error: Class 'My\Addon\XFRM\Pub\Controller\XFCP_ResourceItem' not found in src/addons/My/Addon/XFRM/Pub/Controller/ResourceItem.php

Any help to understanding what I am doing wrong and why it's wrong would be greatly appreciated!
 
I changed the controller to XFRM:ResourceItem and it now works, but I would still like to understand why.
Classes extensions which use the class proxy system are instantiated virtually rather than directly, so from the perspective of XF internals the class you're trying to resolve is still \XFRM\Pub\Controller\ResourceItem.
 
Top Bottom