XF 2.2 Extend XFRM\Search\Data\ResourceItem to add external_url to the search_index

Robert9

Well-known member
I have solved this with a complete replacement of getIndexData();
because i dont know how to use parent:: here.

original:
Code:
    public function getIndexData(Entity $entity)
    {
        /** @var \XFRM\Entity\ResourceItem $entity */

        if (!$entity->Category)
        {
            return null;
        }

        /** @var \XFRM\Entity\ResourceUpdate|null $description */
        $description = $entity->Description;

        $message = $description ? $description->message_  : '';

        $index = IndexRecord::create('resource', $entity->resource_id, [
            'title' => $entity->title_,
            'message' => $entity->tag_line_ . ' ' . $message,
            'date' => $entity->resource_date,
            'user_id' => $entity->user_id,
            'discussion_id' => $entity->resource_id,
            'metadata' => $this->getMetaData($entity)
        ]);

        if (!$entity->isVisible())
        {
            $index->setHidden();
        }

        if ($entity->tags)
        {
            $index->indexTags($entity->tags);
        }

        return $index;
    }


Replacement
Code:
...

        $index = IndexRecord::create('resource', $entity->resource_id, [
            ...
            'message' => $entity->tag_line_ . ' ' . $message . ' ' . $entity->external_url,
            ...
        ]);
...


How i can use parent:: here?
 
Last edited:
Back
Top Bottom