Commit 1f70dd02 authored by Andreas Heimann's avatar Andreas Heimann

added the ability to find a song through the file reference

parent a295071e
......@@ -79,14 +79,20 @@ class APIController extends AbstractController
}
/**
* @Route("/api/song/{id}", name="api.songs.detail")
* @Route("/api/song/{idOrReference}", name="api.songs.detail")
*/
public function songDetail(Request $request, int $id)
public function songDetail(Request $request, $idOrReference)
{
$em = $this->getDoctrine()->getManager();
$data = [];
$result = $em->getRepository(Song::class)->findOneBy(array('id' => $id));
if(is_numeric($idOrReference)) {
// $idOrReference is the ID
$result = $em->getRepository(Song::class)->findOneBy(array('id' => $idOrReference));
} else {
// $idOrReference is the file Reference
$result = $em->getRepository(Song::class)->findOneBy(array('fileReference' => $idOrReference));
}
$baseUrl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
if(!$result) {
......
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