setPollCreator

Ozzy47

Well-known member
So in XF 2.0 and 2.1 we could do something like this:


PHP:
            if ($params['create_poll'])
            {
                // CREATE PROMOTION POLL
                if (!$params['form']->normalpoll && $params['form']->postpoll && $params['form']->pollquestion)
                {
                    $pollCreator = $this->plugin('Snog\Forms:Poll')->setupPollCreate('thread', $creator->getThread(), $params['form'], 1);
                    $creator->setPollCreator($pollCreator);
                }

                // CREATE NORMAL POLL
                if (!$params['form']->postpoll && $params['form']->normalpoll && $params['form']->normalquestion)
                {
                    $pollCreator = $this->plugin('Snog\Forms:Poll')->setupPollCreate('thread', $creator->getThread(), $params['form'], 2);
                    $creator->setPollCreator($pollCreator);
                }
            }

But now in 2.2 it throws an error, presumably due to thread types.

Error: Call to undefined method XF\Service\Thread\Creator::setPollCreator()
src/addons/Snog/Forms/Pub/Controller/Form.php:1619

So what do we need to do to resolve this?
 
Use the setTypeDataSaver method. The poll creator implements the necessary interface, so it's basically a direct swap (though it also supports other thread types, should they require complex data management like polls).
 
Okay, I'm not understanding what to change/do here. Please excuse my ignorance and help a brother out.
 
You should just be able to call the specified method with the poll creator, instead of the old poll-specific method.
 
Top Bottom