XF 2.0 Hooking into post save

_PkZ_

Active member
In XF 1.x i extended DataWriter_DiscussionMessage_Post for parsing attachments when user made a post.
Any hints on how to do that in XF 2.x?

I have been playing with a listener for entity_post_save and entity_post_delete but i am having an hard time understanding the new concepts :)
For example i have not been able to get attachments from the Post entity in those callback functions.

Anybody can point me in the right direction here?
 
you can use XF\Service\
example for use \XF::Sevice to create thread.
PHP:
$creator = \XF::service('XF:Thread\Creator', $forum);
$creator->setContent($title, $message);
$creator->setPrefix($forum['default_prefix_id']);
$creator->setIsAutomated();
$creator->save();
example to create a post
PHP:
$replier = $this->service('XF:Thread\Replier', $thread);
$replier->setMessage($message);
$replier->save();
 
Last edited:
Thank you for your reply!
The thing i need is a hook into the save and delete process for a post. I want to get all attachments attached to the post and then process them some way before the post are saved.

How do you suggest me using XF\Service for that?
 
Thank you for your reply!
The thing i need is a hook into the save and delete process for a post. I want to get all attachments attached to the post and then process them some way before the post are saved.

How do you suggest me using XF\Service for that?
i think it in
XF\Service\Post\Preparer.php
 
Top Bottom