Pimcore\Model\Document\Tag\Wysiwyg::rewriteIds PHP Method

rewriteIds() public method

..), "asset" => array(...) )
public rewriteIds ( array $idMapping ) : void
$idMapping array
return void
    public function rewriteIds($idMapping)
    {
        $html = str_get_html($this->text);
        if (!$html) {
            return $this->text;
        }
        $s = $html->find("a[pimcore_id],img[pimcore_id]");
        if ($s) {
            foreach ($s as $el) {
                if ($el->href || $el->src) {
                    $type = $el->pimcore_type;
                    $id = (int) $el->pimcore_id;
                    if (array_key_exists($type, $idMapping)) {
                        if (array_key_exists($id, $idMapping[$type])) {
                            $el->outertext = str_replace('="' . $el->pimcore_id . '"', '="' . $idMapping[$type][$id] . '"', $el->outertext);
                        }
                    }
                }
            }
        }
        $this->text = $html->save();
        $html->clear();
        unset($html);
    }