php - Symfony 3.1 EventListener method executed two times? -


hello made eventlistener things before send response request. eventlistener:

namespace appbundle\eventlistener;  use symfony\component\httpkernel\event\filtercontrollerevent; use symfony\component\httpfoundation\session\session; use doctrine\orm\entitymanager;  class requestlistener {      private $em;     private $session;      public function __construct(entitymanager $em, session $session) {         $this->em = $em;         $this->session = $session;     }      public function onkernelcontroller(filtercontrollerevent $event) {         $repo=$this->em->getrepository("appbundle:flashmessage");         $repo->addflashmessage("test","content");     }  } 

and add services:

</services>     <service id="app.request.listener" class="appbundle\eventlistener\requestlistener">         <argument type="service" id="doctrine.orm.entity_manager"/>         <argument type="service" id="session" />          <tag name="kernel.event_listener" event="kernel.controller" />     </service> </services> 

every things work fine. fine ! in fact, on each request web browser, 2 entries made in database table (the method onkernelcontroller seem executed 2 times on each request). why 2 entry created on each request ?

edit : php bin/console debug:event-dispatcher| grep -i appbundle give me:

  #1      appbundle\eventlistener\requestlistener::onkernelcontroller()          0    


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -