public function popularTags(Request $request, $taxonomytype)
{
$table = $this->getOption('general/database/prefix');
$table .= 'taxonomy';
$query = $this->createQueryBuilder()->select('name, COUNT(slug) AS count')->from($table)->where('taxonomytype = :taxonomytype')->groupBy('name')->orderBy('count', 'DESC')->setMaxResults($request->query->getInt('limit', 20))->setParameters([':taxonomytype' => $taxonomytype]);
$results = $query->execute()->fetchAll();
usort($results, function ($a, $b) {
if ($a['name'] == $b['name']) {
return 0;
}
return $a['name'] < $b['name'] ? -1 : 1;
});
return $this->json($results);
}