# Controllernamen im Plugin (php)

**URL:** <https://forum.shopware.com/t/controllernamen-im-plugin-php/27987>\
**Category:** Allgemein\
**Created:** [9. Juni 2015 um 12:34 UTC](https://forum.shopware.com/t/controllernamen-im-plugin-php/27987 "2015-06-09T12:34:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [9. Juni 2015 um 12:34 UTC](https://forum.shopware.com/t/controllernamen-im-plugin-php/27987/1 "2015-06-09T12:34:49Z")

</div>

Liebes Forum 🙂 🙂 für ein Plugin benötige ich den Namen des Controller, der für die aufgerufene Seite zuständig ist. Der Controllername wird dem Template als Variable “Controller” übergeben (habe ich in mit der Shopware Developer Toolbar gefunden) und habe versucht sie über $Controllername = $view-\>getAssign(‘Controller’); zu übernehmen. Das liefert aber nur einen leeren Wert. Weiß jemand woran das liegen könnte bzw. wie man an den Controllernamen kommt? Liebe Grüße Kerstin

---

<div class="post-metadata">

**Author:** ![EikeBrandtWarneke](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@EikeBrandtWarneke](https://forum.shopware.com/u/EikeBrandtWarneke)\
**Post date:** [9. Juni 2015 um 13:02 UTC](https://forum.shopware.com/t/controllernamen-im-plugin-php/27987/2 "2015-06-09T13:02:15Z")

</div>

Du kommst über den request und die Methode getControllerName() an den controller. Beispiel: ` public function deinDispatchEvent( \Enlight\_Event\_EventArgs $arguments ) { // get the controller /\* @var $controller \Enlight\_Controller\_Action \*/ $controller = $arguments-\>get( "subject" ); // get request $request = $controller-\>Request(); // get controller name $name = $request-\>getControllerName(); } ` Viele Grüße

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [9. Juni 2015 um 17:49 UTC](https://forum.shopware.com/t/controllernamen-im-plugin-php/27987/3 "2015-06-09T17:49:17Z")

</div>

Vielen Dank, habe ich getestet. Allerdings nimmt Shopware die Zeile 8 $request = $controller-\>Request(); nicht an (das Plugin lässt sich nicht installieren, wenn es diese Zeile enthält). Ist da vielleicht ein Fehler drin? Liebe Grüße Kerstin

---

<div class="post-metadata">

**Author:** ![benblub](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@benblub](https://forum.shopware.com/u/benblub)\
**Post date:** [9. Juni 2015 um 18:09 UTC](https://forum.shopware.com/t/controllernamen-im-plugin-php/27987/4 "2015-06-09T18:09:00Z")

</div>

Hast du das auch mit drinne? `/\* @var $controller \Enlight\_Controller\_Action \*/ $controller = $arguments-\>get( "subject" );` ansonsten halt den Code zeigen…

---

<div class="post-metadata">

**Author:** ![Heiner\_Lohaus](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@Heiner\_Lohaus](https://forum.shopware.com/u/Heiner_Lohaus)\
**Post date:** [9. Juni 2015 um 18:32 UTC](https://forum.shopware.com/t/controllernamen-im-plugin-php/27987/5 "2015-06-09T18:32:27Z")

</div>

Hi, versuche es mal mit: $request = $arguments-\>get( „request“ ); das solle in Front\* und Action\*-Events funktionieren. Heiner

---

<div class="post-metadata">

**Author:** ![Kerstin83](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Kerstin83](https://forum.shopware.com/u/Kerstin83)\
**Post date:** [9. Juni 2015 um 18:39 UTC](https://forum.shopware.com/t/controllernamen-im-plugin-php/27987/6 "2015-06-09T18:39:03Z")

</div>

Ich habe den Code noch einmal kopiert und eingefügt, und jetzt gehts 🙂 🙂 (Habe vorher eigentlich nichts anderes gemacht.) Vielen, vielen Dank. Kleine Nachfrage: Warum hat das nicht mit meinem Code $Controllername = $view-\>getAssign(‚Controller‘); funktioniert? Ich dachte darüber bekommt man alle Templatevariablen. Liebe Grüße Kerstin
