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);
}