/** * @param Request $req * @param Application $app * * @return string */ public function searchAction(Request $req, Application $app) { $errors = array(); $events = array(); $message = ''; $keywords = $req->get('keywords', ''); if ($keywords !== '') { /** @var $token TokenInterface */ $token = $app['security.token_storage']->getToken(); /** @var $user User */ $user = $token->getUser(); if ($app['odbc_aster'] !== false) { // user events $eventsProvider = new EventProvider($app['odbc_aster']); $events = $eventsProvider->getEventsByKeywordsWithInterest($user->getId(), $keywords); if ($events === false) { $errors[] = "Error while retrieving the events of the user! (Bad Query?)"; } } else { $errors[] = "Could not connect to the DB!"; } } return $app['twig']->render('event_search.twig', array('events' => $events, 'message' => $message, 'errors' => $errors, 'page' => 'event_search')); }