Commit be26e605 authored by Andreas Heimann's avatar Andreas Heimann

add searchAll apicall

parent 5424e66b
......@@ -350,4 +350,40 @@ class APIController extends AbstractController
return new JsonResponse(['version' => $this->apiVersion, 'status' => 200, 'data' => $data]);
}
/**
* @Route("/api/searchAll", name="api.search.all")
*/
public function searchAll(Request $request)
{
$em = $this->getDoctrine()->getManager();
$baseUrl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
$data = [];
$data['users'] = [];
$data['songs'] = [];
// Songs
$resultsSongs = $em->getRepository(Song::class)->findAll();
foreach($resultsSongs as $result) {
$oneResult = [];
$oneResult['id'] = $result->getId();
$oneResult['title'] = $result->getTitle();
$oneResult['subtitle'] = $result->getSubtitle();
$oneResult['artist'] = $result->getArtist();
$oneResult['charter'] = $result->getCharter();
$oneResult['hasEasyDifficulty'] = $result->getHasEasyDifficulty();
$oneResult['hasNormalDifficulty'] = $result->getHasNormalDifficulty();
$oneResult['hasHardDifficulty'] = $result->getHasHardDifficulty();
$oneResult['hasExtremeDifficulty'] = $result->getHasExtremeDifficulty();
$oneResult['hasXDDifficulty'] = $result->getHasXDDifficulty();
$oneResult['cover'] = $baseUrl."/uploads/cover/".$result->getFileReference().".png";
$data['songs'][] = $oneResult;
}
return new JsonResponse(['version' => $this->apiVersion, 'status' => 200, 'data' => $data]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment