<commit_before><?php

namespace Keosu\Gadget\MapGadgetBundle\EventListener;

use Keosu\CoreBundle\KeosuEvents;
use Keosu\CoreBundle\Event\GadgetFormBuilderEvent;
use keosu\CoreBundle\Event\GadgetSaveConfigEvent;

use Keosu\Gadget\MapGadgetBundle\KeosuGadgetMapGadgetBundle;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Listener responsible to gadget action
 */
class GadgetListener implements EventSubscriberInterface
{

	private $container;

	public function __construct($container)
	{
		$this->container = $container;
	}

	/**
	 * {@inheritDoc}
	 */
	public static function getSubscribedEvents()
	{
		return array(
			KeosuEvents::GADGET_CONF_FORM_BUILD.KeosuGadgetMapGadgetBundle::PACKAGE_NAME => 'onGadgetConfFormBuild',
		);
	}

	public function onGadgetConfFormBuild(GadgetFormBuilderEvent $event)
	{
		$event->setOverrideForm(true);
		$em = $this->container->get('doctrine')->getManager();
		
		
		
		$zoomList = array();
		for ($i = 1; $i <= 17; $i++) {
			$zoomList[$i]=$i;
		}
		
		//Overide form
		$builder = $event->getFormBuilder();
		$builder->add('poiId','number')
					->add('zoom','choice',array(
							'choices'	=> $zoomList,
					));
		
	}
}
<commit_msg>Add a list for select a poi in the map gadget form.<commit_after><?php

namespace Keosu\Gadget\MapGadgetBundle\EventListener;

use Keosu\CoreBundle\KeosuEvents;
use Keosu\CoreBundle\Event\GadgetFormBuilderEvent;
use keosu\CoreBundle\Event\GadgetSaveConfigEvent;

use Keosu\Gadget\MapGadgetBundle\KeosuGadgetMapGadgetBundle;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Listener responsible to gadget action
 */
class GadgetListener implements EventSubscriberInterface
{

	private $container;

	public function __construct($container)
	{
		$this->container = $container;
	}

	/**
	 * {@inheritDoc}
	 */
	public static function getSubscribedEvents()
	{
		return array(
			KeosuEvents::GADGET_CONF_FORM_BUILD.KeosuGadgetMapGadgetBundle::PACKAGE_NAME => 'onGadgetConfFormBuild',
		);
	}

	public function onGadgetConfFormBuild(GadgetFormBuilderEvent $event)
	{
		$event->setOverrideForm(true);
		$em = $this->container->get('doctrine')->getManager();
		
		//Get list of Point of interest
		$queryPOIList = $em->createQueryBuilder();
		$queryPOIList->add('select','l.id, l.name')
						->add('from', 'Keosu\DataModel\LocationModelBundle\Entity\Location l');
		$poiListTmp=$queryPOIList->getQuery()->execute();
		

		//Prepare the list of poi for the form
		$articleList=array();
		foreach($poiListTmp as $poi){
			$poiList[$poi['id']]=$poi['name'];
		}
		
		//Prepare the list of zoom choices
		for ($i = 1; $i <= 17; $i++) {
			$zoomList[$i]=$i;
		}
		
		//Overide form
		$builder = $event->getFormBuilder();
		$builder->add('poiId','choice',array(
						'label' 	=> 'Point of interest',
						'choices'	=> $poiList
					))
					->add('zoom','choice',array(
							'choices'	=> $zoomList,
					));
		
	}
}

{'fraction_non_alphanumeric': 0.1446111869031378, 'fraction_numerical': 0.0020463847203274215, 'mean_word_length': 4.565464895635674, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3522569', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1024, 'n_words': 172}