aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/api/controllers/Links.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/api/controllers/Links.php')
-rw-r--r--application/api/controllers/Links.php5
1 files changed, 4 insertions, 1 deletions
diff --git a/application/api/controllers/Links.php b/application/api/controllers/Links.php
index a40e974d..eb78dd26 100644
--- a/application/api/controllers/Links.php
+++ b/application/api/controllers/Links.php
@@ -141,6 +141,7 @@ class Links extends ApiController
141 141
142 $this->linkDb[$link['id']] = $link; 142 $this->linkDb[$link['id']] = $link;
143 $this->linkDb->save($this->conf->get('resource.page_cache')); 143 $this->linkDb->save($this->conf->get('resource.page_cache'));
144 $this->history->addLink($link);
144 $out = ApiUtils::formatLink($link, index_url($this->ci['environment'])); 145 $out = ApiUtils::formatLink($link, index_url($this->ci['environment']));
145 $redirect = $this->ci->router->relativePathFor('getLink', ['id' => $link['id']]); 146 $redirect = $this->ci->router->relativePathFor('getLink', ['id' => $link['id']]);
146 return $response->withAddedHeader('Location', $redirect) 147 return $response->withAddedHeader('Location', $redirect)
@@ -184,6 +185,7 @@ class Links extends ApiController
184 $responseLink = ApiUtils::updateLink($responseLink, $requestLink); 185 $responseLink = ApiUtils::updateLink($responseLink, $requestLink);
185 $this->linkDb[$responseLink['id']] = $responseLink; 186 $this->linkDb[$responseLink['id']] = $responseLink;
186 $this->linkDb->save($this->conf->get('resource.page_cache')); 187 $this->linkDb->save($this->conf->get('resource.page_cache'));
188 $this->history->updateLink($responseLink);
187 189
188 $out = ApiUtils::formatLink($responseLink, $index); 190 $out = ApiUtils::formatLink($responseLink, $index);
189 return $response->withJson($out, 200, $this->jsonStyle); 191 return $response->withJson($out, 200, $this->jsonStyle);
@@ -205,9 +207,10 @@ class Links extends ApiController
205 if (! isset($this->linkDb[$args['id']])) { 207 if (! isset($this->linkDb[$args['id']])) {
206 throw new ApiLinkNotFoundException(); 208 throw new ApiLinkNotFoundException();
207 } 209 }
208 210 $link = $this->linkDb[$args['id']];
209 unset($this->linkDb[(int) $args['id']]); 211 unset($this->linkDb[(int) $args['id']]);
210 $this->linkDb->save($this->conf->get('resource.page_cache')); 212 $this->linkDb->save($this->conf->get('resource.page_cache'));
213 $this->history->deleteLink($link);
211 214
212 return $response->withStatus(204); 215 return $response->withStatus(204);
213 } 216 }