if ($layer->hasFeatureInfo() && isset($_GET['l' . $layer->getId()]) == 'true') { //isset toegevoegd na foutmelding $layers[$layer->getLegendName()] = $app['orm.em']->getRepository(':Node')->findInCircle($layer, $_GET['x'], $_GET['y'], $_GET['res']); } } return $app['twig']->render('object.twig', array('layers' => $layers)); }); $app->match('ajax/polygon', function (Application $app) { $points = $_GET['points']; $tempLayers = $app['orm.em']->getRepository(':Layer')->findBy(array()); $layers = []; foreach ($tempLayers as $layer) { if ($layer->hasFeatureInfo() && isset($_GET['l' . $layer->getId()]) == 'true') { //isset toegevoegd na foutmelding $layers[$layer->getLegendName()] = $app['orm.em']->getRepository(':Node')->findInPolygon($points, $layer); } } return $app['twig']->render('object.twig', array('layers' => $layers)); }); $app->match('ajax/closest', function (Application $app) { $layers = array_filter($app['orm.em']->getRepository(':Layer')->findBy(array()), function ($layer) { return $layer->hasFeatureInfo() && isset($_GET['l' . $layer->getId()]) == 'true'; }); $node = $app['orm.em']->getRepository(':Node')->findClosest($layers, $_GET['x'], $_GET['y'], $_GET['res']); if (empty($node)) { throw $app->createNotFoundException('No node nearby.'); } return $app->json($node[0]->getId()); }); include $config['wiki_dir'] . '/app/common_app.php'; return $app;
/** * @param \Application $app * @param Request $request * @return \Symfony\Component\HttpFoundation\JsonResponse */ public function post(\Application $app, Request $request) { return $app->json($request->request->all()); }
/** * Session information manager. * * @param Application $app The silex app. * @param $id A session id [optionally]. * * @return string */ public function getSession(Application $app, $id = '') { $socket = new Socket(); $result = $socket->getSession($id); return $app->json($result); }