XF 2.2 Can I get some info on why the Poll Thread Type always has to be "poll" discussion_type?

robdog

Well-known member
This one was causing me a bit of an issue, but I was wondering why we are forcing the discussion_type value to be "poll"? The reason why I ran into this is because I wanted to leverage all the poll functionality into another discussion_type. I am collecting additional information on the new discussion type but it will have a different name.

During the save process it is trying to switch it back to "poll" which will have some adverse affects. I am going to attempt to simply extend the poll handler and see if I can override the finalizeCreation and finalizeDeletion functionality.

PHP:
    public function finalizeCreation(Entity $content, Poll $poll)
    {
        /** @var \XF\Entity\Thread $content */
        if ($content->discussion_type != 'poll')
        {
            $content->discussion_type = 'poll';
            $content->save();
        }
    }

    public function finalizeDeletion(Entity $content, Poll $poll)
    {
        /** @var \XF\Entity\Thread $content */
        if ($content->discussion_type == 'poll')
        {
            $content->discussion_type = '';
            $content->save();
        }
    }

Thanks for any info.

Side Note: Attempting to extend the handler class does not have any affect.
 
Back
Top Bottom