aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/api/controllers/Links.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-05-07 16:50:20 +0200
committerArthurHoaro <arthur@hoa.ro>2017-05-07 17:11:22 +0200
commit813849e5216cb87121e0f778a734575be6a36052 (patch)
tree45605ad43e3f751eba51d19f8c6955c3824e8d32 /application/api/controllers/Links.php
parenta4af59f47103a3f9c903eeddb1e30ab9cb7344f0 (diff)
downloadShaarli-813849e5216cb87121e0f778a734575be6a36052.tar.gz
Shaarli-813849e5216cb87121e0f778a734575be6a36052.tar.zst
Shaarli-813849e5216cb87121e0f778a734575be6a36052.zip
Add history entries for API endpoint
CHANGED: datetime is now store as an object in history store file
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 }