XF 2.1 What I'm missing to get an instance of XenForo_Model_Thread

Cylon

Member
Dear friends,

I'm developing an Addon, that expands the XF rest Api with some endpoints that I need for the client app that I'm developing.

For example, I'm missing in the official rest API an endpoint to mark a thread as read, because of that I'm writing myself endpoint.

I searched across the source code and found that the function that marks a thread as read lives in the XenForo_Model_Thread class, and that this class is instantiated in the following way:


Code:
/* @var $threadModel \XenForo_Model_Thread */
        $threadModel = \XenForo_Model::create( "XenForo_Model_Thread" );


        $threadModel->markThreadRead();

That's the source code that I'm using in my custom controller, in my custom endpoint. My custom controller extends the class XF\Api\Controller\Thread and it is working very well (for the other endpoints that I implemented).

But when calling, \XenForo_Model::create( "XenForo_Model_Thread" ), the following exception happens: "Class 'XenForo_Application' not found"

As said in another thread, I'm newbie to the Xenforo development, and I'm pretty sure that I'm missing something. I read the docus available again, especially all related to the autoload features, but I did not find what I'm doing wrong.

Do I have to require some PHP classes in my custom endpoints to access the XF framework? Or maybe am I extending the wrong class for my custom endpoint?

Thanks in advance and excuse my poor English.

Cylon
 
\XenForo_Model_Thread (and any other code from the library/ directory) is from XF1. To mark a thread as read in XF2, you'd use markThreadReadByUser() or a similar method from \XF\Repository\Thread.
 
Thank you for your super fast answer!!!

Now I'm a little bit worried. Is it normal that after upgrading to xf 2.1 the old xf 1 files are there?

Is the library folder necessary for xf2 or can I delete it? And when yes, are there other folders from xf1 that are not more used in xf2? I would like to clean up my installation...

Thanks!
 
Back
Top Bottom