+ protected function updateReferencesWithinEntity(Entity $entity, string $oldLink, string $newLink): void
+ {
+ if ($entity instanceof Page) {
+ $this->updateReferencesWithinPage($entity, $oldLink, $newLink);
+ return;
+ }
+
+ if (in_array(HasHtmlDescription::class, class_uses($entity))) {
+ $this->updateReferencesWithinDescription($entity, $oldLink, $newLink);
+ }
+ }
+
+ protected function updateReferencesWithinDescription(Entity $entity, string $oldLink, string $newLink): void
+ {
+ /** @var HasHtmlDescription&Entity $entity */
+ $entity = (clone $entity)->refresh();
+ $html = $this->updateLinksInHtml($entity->description_html ?: '', $oldLink, $newLink);
+ $entity->description_html = $html;
+ $entity->save();
+ }
+
+ protected function updateReferencesWithinPage(Page $page, string $oldLink, string $newLink): void