# \[Gelöst\]\[Plugin\] Mehrere Events Subscriben

**URL:** <https://forum.shopware.com/t/gelost-plugin-mehrere-events-subscriben/38371>\
**Category:** Programmierung\
**Created:** [19. Juli 2016 um 15:49 UTC](https://forum.shopware.com/t/gelost-plugin-mehrere-events-subscriben/38371 "2016-07-19T15:49:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Geloschter\_Benutze7](https://avatars.discourse-cdn.com/v4/letter/_/cdc98d/32.png) [@\_Geloschter\_Benutze7](https://forum.shopware.com/u/_Geloschter_Benutze7)\
**Post date:** [19. Juli 2016 um 15:49 UTC](https://forum.shopware.com/t/gelost-plugin-mehrere-events-subscriben/38371/1 "2016-07-19T15:49:25Z")

</div>

Hallo,&nbsp;

ich möchte über mein Plugin Bootstrap mehere Events Subscriben.&nbsp;

Wie folgt:

/\*\*  
&nbsp;\* Register Eventhandler method  
\*/  
private function registerEvents() {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-\>subscribeEvent(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘Enlight\_Controller\_Action\_PostDispatchSecure\_Frontend\_Detail’,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘onPostDispatchDetail’  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-\>subscribeEvent(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘Enlight\_Controller\_Action\_PostDispatchSecure\_Frontend\_Listing’,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘onPostDispatchListing’  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-\>subscribeEvent(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘Enlight\_Controller\_Action\_PostDispatchSecure\_Frontend\_Search’,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;‘onPostDispatchSearch’ );  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

}

Meine Frage wäre, kann man nur ein Event Subscriben oder wo liegt der Fehler?

Was vielleicht auch noch falsch ist:

public function onPostDispatchDetail(Enlight\_Event\_EventArgs $arguments)  
{  
&nbsp;&nbsp;&nbsp;&nbsp;/\*\*  
&nbsp;&nbsp;&nbsp;&nbsp;\* Add Template directory to global Template Scope  
&nbsp;&nbsp;&nbsp;&nbsp;\*/  
&nbsp;&nbsp;&nbsp;&nbsp;$view-\>addTemplateDir($this-\>Path() . ‘Views/detail/’);  
}

Ich deklariere für jedes Event den dazugehörigen View ordner, ist das auch falsch?

Vielen Dank,&nbsp;  
Brian Schäffner

---

<div class="post-metadata">

**Author:** ![Synonymous](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Synonymous](https://forum.shopware.com/u/Synonymous)\
**Post date:** [19. Juli 2016 um 16:36 UTC](https://forum.shopware.com/t/gelost-plugin-mehrere-events-subscriben/38371/2 "2016-07-19T16:36:40Z")

</div>

Hilfreich wäre zu wissen, was denn der Fehler ist… Rufst Du die registerEvents() Methode in der install() Methode der Bootstrap Klasse auf? Danach Plugin neu installiert? Sonst werden die Eventlistener nicht eingetragen.

---

<div class="post-metadata">

**Author:** ![\_Geloschter\_Benutze7](https://avatars.discourse-cdn.com/v4/letter/_/cdc98d/32.png) [@\_Geloschter\_Benutze7](https://forum.shopware.com/u/_Geloschter_Benutze7)\
**Post date:** [20. Juli 2016 um 07:32 UTC](https://forum.shopware.com/t/gelost-plugin-mehrere-events-subscriben/38371/3 "2016-07-20T07:32:11Z")

</div>

Hallo,&nbsp;

ich rufe die registerEventsMethode in der install Method auf, das hat funktioniert als ich nur&nbsp;Enlight\_Controller\_Action\_PostDispatchSecure\_Frontend\_Detail hatte.  
Habe auch das Plugin neu installiert.&nbsp;

Mein Problem ist damit die Variablen der View zugewiesen werden aber die Views nicht verwendet werden.&nbsp;  
Bei Enlight\_Controller\_Action\_PostDispatchSecure\_Frontend\_Detail hat es funktioniert, aber als ich die anderen Events dazugenommen habe, wird keine View mehr von meinem Plugin benutzt,&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![\_Geloschter\_Benutze7](https://avatars.discourse-cdn.com/v4/letter/_/cdc98d/32.png) [@\_Geloschter\_Benutze7](https://forum.shopware.com/u/_Geloschter_Benutze7)\
**Post date:** [20. Juli 2016 um 08:12 UTC](https://forum.shopware.com/t/gelost-plugin-mehrere-events-subscriben/38371/4 "2016-07-20T08:12:51Z")

</div>

Hat sich erledigt, der Fehler war:  
&nbsp;

public function onPostDispatchDetail(Enlight\_Event\_EventArgs $arguments)  
{  
&nbsp;&nbsp;&nbsp;&nbsp;/\*\*  
&nbsp;&nbsp;&nbsp;&nbsp;\* Add Template directory to global Template Scope  
&nbsp;&nbsp;&nbsp;&nbsp;\*/  
&nbsp;&nbsp;&nbsp;&nbsp;$view-\>addTemplateDir($this-\>Path() . 'Views/ -\> detail/ }

Das muss ohne detail sein.&nbsp;
