Moved tag autocompleting to API

This commit is contained in:
Marcin Kurczewski 2014-05-04 09:20:13 +02:00
parent 1787604ac1
commit 26323f996b
2 changed files with 13 additions and 10 deletions

View file

@ -125,10 +125,10 @@ $tagValidation =
\Chibi\Router::register(['TagController', 'listView'], 'GET', '/tags', $tagValidation);
\Chibi\Router::register(['TagController', 'listView'], 'GET', '/tags/{page}', $tagValidation);
\Chibi\Router::register(['TagController', 'listView'], 'GET', '/tags/{filter}/{page}', $tagValidation);
\Chibi\Router::register(['TagController', 'autoCompleteView'], 'GET', '/tags-autocomplete', $tagValidation);
foreach (['GET', 'POST'] as $method)
{
\Chibi\Router::register(['TagController', 'autoCompleteAction'], $method, '/tags-autocomplete', $tagValidation);
\Chibi\Router::register(['TagController', 'relatedAction'], $method, '/tags-related', $tagValidation);
\Chibi\Router::register(['TagController', 'mergeAction'], $method, '/tags-merge', $tagValidation);
\Chibi\Router::register(['TagController', 'renameAction'], $method, '/tags-rename', $tagValidation);

View file

@ -18,16 +18,19 @@ class TagController
$context->transport->paginator = $ret;
}
public function autoCompleteAction()
public function autoCompleteView()
{
$filter = InputHelper::get('search');
$filter .= ' order:popularity,desc';
$ret = Api::run(
(new ListTagsJob)->setPageSize(15),
[
ListTagsJob::QUERY => $filter,
ListTagsJob::PAGE_NUMBER => 1,
]);
$context = getContext();
Access::assert(Privilege::ListTags);
$suppliedSearch = InputHelper::get('search');
$filter = $suppliedSearch . ' order:popularity,desc';
$tags = TagSearchService::getEntitiesRows($filter, 15, 1);
$context->transport->tags =
array_values(array_map(
function($tag)
@ -36,7 +39,7 @@ class TagController
'name' => $tag['name'],
'count' => $tag['post_count']
];
}, $tags));
}, $ret->entities));
}
public function relatedAction()