<commit_before><?php

namespace Keosu\Gadget\LastArticleGadgetBundle\EventListener;

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

use Keosu\Gadget\LastArticleGadgetBundle\KeosuGadgetLastArticleGadgetBundle;

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.KeosuGadgetLastArticleGadgetBundle::PACKAGE_NAME => 'onGadgetConfFormBuild',
			KeosuEvents::GADGET_CONF_SAV.KeosuGadgetLastArticleGadgetBundle::PACKAGE_NAME        => 'onGadgetConfSav',
		);
	}

	public function onGadgetConfFormBuild(GadgetFormBuilderEvent $event)
	{
		$event->setOverrideForm(true);
		$appid = $this->container->get('keosu_core.curapp')->getCurApp();
		$em = $this->container->get('doctrine')->getManager();
		
		//Get list of tag
		$queryTagList = $em->createQueryBuilder();
		$queryTagList->add('select','DISTINCT t.tagName')
						->add('from', 'Keosu\DataModel\ArticleModelBundle\Entity\ArticleTags t');
		$tagListTmp=$queryTagList->getQuery()->execute();

		$tagList=array();
		foreach($tagListTmp as $tag){
			$tagList[$tag['tagName']]=$tag['tagName'];
		}
		
		
		//Overide form
		$builder = $event->getFormBuilder();
		$builder->add('tag','choice',array(
				'choices'	=> $tagList,
				'required'	=> false	
		));
		
	}
	
	public function onGadgetConfSav(GadgetSaveConfigEvent $event)
	{

	}
}
<commit_msg>Remove useless code in last article gadget eventListener.<commit_after><?php

namespace Keosu\Gadget\LastArticleGadgetBundle\EventListener;

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

use Keosu\Gadget\LastArticleGadgetBundle\KeosuGadgetLastArticleGadgetBundle;

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.KeosuGadgetLastArticleGadgetBundle::PACKAGE_NAME => 'onGadgetConfFormBuild',
		);
	}

	public function onGadgetConfFormBuild(GadgetFormBuilderEvent $event)
	{
		$event->setOverrideForm(true);
		$em = $this->container->get('doctrine')->getManager();
		
		//Get list of tag
		$queryTagList = $em->createQueryBuilder();
		$queryTagList->add('select','DISTINCT t.tagName')
						->add('from', 'Keosu\DataModel\ArticleModelBundle\Entity\ArticleTags t');
		$tagListTmp=$queryTagList->getQuery()->execute();

		$tagList=array();
		foreach($tagListTmp as $tag){
			$tagList[$tag['tagName']]=$tag['tagName'];
		}
		
		
		//Overide form
		$builder = $event->getFormBuilder();
		$builder->add('tag','choice',array(
				'choices'	=> $tagList,
				'required'	=> false	
		));
		
	}
}

{'fraction_non_alphanumeric': 0.13775198533903482, 'fraction_numerical': 0.0, 'mean_word_length': 5.498015873015873, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '260569', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1110, 'n_words': 157}