Cylon
Member
Dear Friends,
for my addon, I extended some classes, like for example the \XF\Service\PushNotification class. For that I created an extension class, under development->Class extension, then the file extension_hint.php is created in my project, with the following:
namespace MyCompany\MyAddon\XF\Service
{
class XFCP_PushNotification extends \XF\Service\PushNotification {}
}
Then in my addon, I create a class that extends XFCP_PushNotification , and all works as expected. The functions in the extension class are called as expected.
But I'm having trouble extending the classes under \XF\Api\Controller\, for example, the \XF\Api\Controller\Thread class. I do the same process, and the proxy alias is created in the file extension_hint.php:
namespace MyCompany\MyAddon\Api\Controller
{
class XFCP_CustomThreadController extends \XF\Api\Controller\Thread {}
}
Then in my custom controller:
namespace MyCompany\MyAddon\Api\Controller;
class CustomThreadController extends XFCP_CustomThreadController {
.....
}
Then, when doing a rest request to this controller, the following error happens:
<br />
<b>Fatal error</b>: Class 'MyCompany\MyAddon\Api\Controller\XFCP_CustomThreadController ' not found in
<b>/vagrant/src/addons/MyCompany/MyAddon/Api/Controller/CustomThreadController .php</b> on line <b>12</b><br />
although phpstorm detects the proxy class without problems.
But If I extend my custom controller direct from \XF\Api\Controller\Thread then all works as expected.
Finally, the question is, do we have to use the XFCP system when extending the classes under \XF\Api? What I'm doing wrong?
Thanks in advance!
for my addon, I extended some classes, like for example the \XF\Service\PushNotification class. For that I created an extension class, under development->Class extension, then the file extension_hint.php is created in my project, with the following:
namespace MyCompany\MyAddon\XF\Service
{
class XFCP_PushNotification extends \XF\Service\PushNotification {}
}
Then in my addon, I create a class that extends XFCP_PushNotification , and all works as expected. The functions in the extension class are called as expected.
But I'm having trouble extending the classes under \XF\Api\Controller\, for example, the \XF\Api\Controller\Thread class. I do the same process, and the proxy alias is created in the file extension_hint.php:
namespace MyCompany\MyAddon\Api\Controller
{
class XFCP_CustomThreadController extends \XF\Api\Controller\Thread {}
}
Then in my custom controller:
namespace MyCompany\MyAddon\Api\Controller;
class CustomThreadController extends XFCP_CustomThreadController {
.....
}
Then, when doing a rest request to this controller, the following error happens:
<br />
<b>Fatal error</b>: Class 'MyCompany\MyAddon\Api\Controller\XFCP_CustomThreadController ' not found in
<b>/vagrant/src/addons/MyCompany/MyAddon/Api/Controller/CustomThreadController .php</b> on line <b>12</b><br />
although phpstorm detects the proxy class without problems.
But If I extend my custom controller direct from \XF\Api\Controller\Thread then all works as expected.
Finally, the question is, do we have to use the XFCP system when extending the classes under \XF\Api? What I'm doing wrong?
Thanks in advance!