Added option to set tags while creating short code from rest API

This commit is contained in:
Alejandro Celaya
2016-08-21 13:07:12 +02:00
parent 322180bde4
commit b6fee0ebaf
2 changed files with 11 additions and 7 deletions

View File

@@ -66,9 +66,10 @@ class CreateShortcodeAction extends AbstractRestAction
], 400);
}
$longUrl = $postData['longUrl'];
$tags = isset($postData['tags']) && is_array($postData['tags']) ? $postData['tags'] : [];
try {
$shortCode = $this->urlShortener->urlToShortCode(new Uri($longUrl));
$shortCode = $this->urlShortener->urlToShortCode(new Uri($longUrl), $tags);
$shortUrl = (new Uri())->withPath($shortCode)
->withScheme($this->domainConfig['schema'])
->withHost($this->domainConfig['hostname']);