- $link['id'] = $this->linkDb->getNextId();
- $link['shorturl'] = link_small_hash($link['created'], $link['id']);
-
- // note: general relative URL
- if (empty($link['url'])) {
- $link['url'] = '?' . $link['shorturl'];
- }
-
- if (empty($link['title'])) {
- $link['title'] = $link['url'];
- }
-
- $this->linkDb[$link['id']] = $link;
- $this->linkDb->save($this->conf->get('resource.page_cache'));
- $this->history->addLink($link);
- $out = ApiUtils::formatLink($link, index_url($this->ci['environment']));
- $redirect = $this->ci->router->relativePathFor('getLink', ['id' => $link['id']]);
+ $this->bookmarkService->add($bookmark);
+ $out = ApiUtils::formatLink($bookmark, index_url($this->ci['environment']));
+ $redirect = $this->ci->router->pathFor('getLink', ['id' => $bookmark->getId()]);