Lack of interest AbstractPrefix import data class missing

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

Jake B.

Well-known member
Wasn't sure whether this made sense as a bug or suggestion so just threw it in suggestions -- assuming it's something that is planned once there is an importer which requires it, but was building an custom importer for a client that does require it and noticed it didn't exist so temporarily have created my own
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.
My AbstractPrefixGroup:

PHP:
use XF\Import\Data\AbstractEmulatedData;

abstract class AbstractPrefixGroup extends AbstractEmulatedData
{
    protected $title = '';

    public function setTitle($title)
    {
        $this->title = $title;
    }

    protected function postSave($oldId, $newId)
    {
        /** @var \XF\Entity\AbstractPrefixGroup $prefixGroup */
        $prefixGroup = $this->em()->find($this->getEntityShortName(), $newId);
        if ($prefixGroup)
        {
            $this->insertMasterPhrase($prefixGroup->getPhraseName(), $this->title);

            $this->em()->detachEntity($prefixGroup);
        }
    }
}

and AbstractPrefix:

PHP:
use XF\Import\Data\AbstractEmulatedData;

abstract class AbstractPrefix extends AbstractEmulatedData
{
    protected $title = '';

    public function setTitle($title)
    {
        $this->title = $title;
    }

    protected function postSave($oldId, $newId)
    {
        /** @var \XF\Entity\AbstractPrefix $prefix */
        $prefix = $this->em()->find($this->getEntityShortName(), $newId);
        if ($prefix)
        {
            $this->insertMasterPhrase($prefix->getPhraseName(), $this->title);

            $this->em()->detachEntity($prefix);
        }

        /** @var \XF\Repository\AbstractPrefix $repo */
        $repo = $this->repository($this->getEntityShortName());

        \XF::runOnce('rebuildPrefixImport-' . $this->getEntityShortName(), function() use ($repo)
        {
            $repo->rebuildPrefixCache();
        });
    }
}

Basically just copied and adapted from the included AbstractField
 
Back
Top Bottom