Controller/GeolocatorController.php
public function locate($entity, Request $request, $template = null)
    {
        if (!$template) {
            $template = 'TenelevenGeolocatorBundle::results.html.twig';
        }

        $provider = $this->getLocationProvider($entity);
        $form = $this->get('form.factory')->createNamed('', $provider->getFilterFormType(), null, array(
            'method' => 'GET', 
            'csrf_protection' => false,
            'allow_extra_fields' => true,
        ));
        
        foreach ($request->query->all() as $key => $value) {
            if ($form->has($key)) {
                continue;
            }
            
            $form->add($key, HiddenType::class, [
                'data' => $value,
            ]);
        }

        try {
            $form->handleRequest($request);
        } catch (QuotaExceeded $e) {
            $this->get('logger')->error($e->getMessage());
            $this->get('session')->getFlashBag()->add('error', 'Sorry, this locator has exceeded the quota for location look-ups. Please try again at a later time.');
        }

        if (!$form->isValid()) {
            return $this->render($template, array(
                'map' => $map = $this->getMap(),
                'form' => $form->createView()
            ));
        }

        $result = $provider->findLocations($form);
        $map = $this->buildMap($template, $result);

        return $this->render($template, array(
            'form' => $form->createView(),
            'result' => $result,
            'map' => $map
        ));
    }
public function locate($entity, Request $request, $template = null)
    {
        if (!$template) {
            $template = 'TenelevenGeolocatorBundle::results.html.twig';
        }

        $provider = $this->getLocationProvider($entity);
        $form = $this->get('form.factory')->createNamed('', $provider->getFilterFormType(), null, array(
            'method' => 'GET', 
            'csrf_protection' => false,
            'allow_extra_fields' => true,
        ));
        
        foreach ($request->query->all() as $key => $value) {
            if ($form->has($key)) {
                continue;
            }
            
            $form->add($key, HiddenType::class, [
                'data' => $value,
            ]);
        }

        try {
            $form->handleRequest($request);
        } catch (QuotaExceeded $e) {
            $this->get('logger')->error($e->getMessage());
            $this->get('session')->getFlashBag()->add('error', 'Sorry, this locator has exceeded the quota for location look-ups. Please try again at a later time.');
        }

        if (!$form->isValid()) {
            return $this->render($template, array(
                'map' => $map = $this->getMap(),
                'form' => $form->createView()
            ));
        }

        $result = $provider->findLocations($form);
        $map = $this->buildMap($template, $result);

        return $this->render($template, array(
            'form' => $form->createView(),
            'result' => $result,
            'map' => $map
        ));
    }
public function locate ( $ entity , Request $ request , $ template = null ) { if ( ! $ template ) { $ template = 'TenelevenGeolocatorBundle::results.html.twig' ; } $ provider = $ this -> getLocationProvider ( $ entity ) ; $ form = $ this -> get ( 'form.factory' ) -> createNamed ( '' , $ provider -> getFilterFormType ( ) , null , array ( 'method' => 'GET' , 'csrf_protection' => false , 'allow_extra_fields' => true , ) ) ; foreach ( $ request -> query -> all ( ) as $ key => $ value ) { if ( $ form -> has ( $ key ) ) { continue ; } $ form -> add ( $ key , HiddenType :: class , [ 'data' => $ value , ] ) ; } try { $ form -> handleRequest ( $ request ) ; } catch ( QuotaExceeded $ e ) { $ this -> get ( 'logger' ) -> error ( $ e -> getMessage ( ) ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'error' , 'Sorry, this locator has exceeded the quota for location look-ups. Please try again at a later time.' ) ; } if ( ! $ form -> isValid ( ) ) { return $ this -> render ( $ template , array ( 'map' => $ map = $ this -> getMap ( ) , 'form' => $ form -> createView ( ) ) ) ; } $ result = $ provider -> findLocations ( $ form ) ; $ map = $ this -> buildMap ( $ template , $ result ) ; return $ this -> render ( $ template , array ( 'form' => $ form -> createView ( ) , 'result' => $ result , 'map' => $ map ) ) ; }
Displays a geo-locator screen with map, form, and locations

@param string  $entity   The entity key that the provider is registered under
@param Request $request
@param string  $template The template to render

@return Response
Displays a geo - locator screen with map form and locations