예제 #1
0
 /**
  * Searches for a track and gives the response
  * 
  * @Route("/searchwidget/{query}", name="searchwidget")
  */
 public function searchWidgetAction($query)
 {
     $lastFmCrawler = new LastFMCrawler();
     $songs = $lastFmCrawler->searchTrack($query, 1, 5);
     $json = array();
     foreach ($songs as $track) {
         $json[] = array('artist' => $track->getArtist()->getName(), 'title' => $track->getTitle(), 'youtube' => $track->getYoutube());
     }
     return new JsonResponse($json);
 }