diff options
author | ArthurHoaro <arthur@hoa.ro> | 2018-05-19 15:04:04 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2018-06-04 18:51:22 +0200 |
commit | d3f42ca487287447efb81061609644108044a038 (patch) | |
tree | 6e9d5a33290f857c8f7a04dbdf8cf0ca749db149 /application/api/ApiUtils.php | |
parent | 17e45b2e9c33c736751e059276fadb480f98e621 (diff) | |
download | Shaarli-d3f42ca487287447efb81061609644108044a038.tar.gz Shaarli-d3f42ca487287447efb81061609644108044a038.tar.zst Shaarli-d3f42ca487287447efb81061609644108044a038.zip |
Implements Tags endpoints for Shaarli's REST API
Endpoints:
* List All Tags [GET]
* Get a tag [GET]
* Update a tag [PUT]
* Delete a tag [DELETE]
Fixes #904
References shaarli/api-documentation#34
Diffstat (limited to 'application/api/ApiUtils.php')
-rw-r--r-- | application/api/ApiUtils.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/application/api/ApiUtils.php b/application/api/ApiUtils.php index f154bb52..fc5ecaf1 100644 --- a/application/api/ApiUtils.php +++ b/application/api/ApiUtils.php | |||
@@ -134,4 +134,20 @@ class ApiUtils | |||
134 | 134 | ||
135 | return $oldLink; | 135 | return $oldLink; |
136 | } | 136 | } |
137 | |||
138 | /** | ||
139 | * Format a Tag for the REST API. | ||
140 | * | ||
141 | * @param string $tag Tag name | ||
142 | * @param int $occurrences Number of links using this tag | ||
143 | * | ||
144 | * @return array Link data formatted for the REST API. | ||
145 | */ | ||
146 | public static function formatTag($tag, $occurences) | ||
147 | { | ||
148 | return [ | ||
149 | 'name' => $tag, | ||
150 | 'occurrences' => $occurences, | ||
151 | ]; | ||
152 | } | ||
137 | } | 153 | } |