# Problem mit Hooks

**URL:** <https://forum.shopware.com/t/problem-mit-hooks/7834>\
**Category:** Shopware 3.5\
**Tags:** general\
**Created:** [25. Juli 2012 um 09:13 UTC](https://forum.shopware.com/t/problem-mit-hooks/7834 "2012-07-25T09:13:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fdehn](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/fdehn/32/86_2.png) [@fdehn](https://forum.shopware.com/u/fdehn)\
**Post date:** [25. Juli 2012 um 09:13 UTC](https://forum.shopware.com/t/problem-mit-hooks/7834/1 "2012-07-25T09:13:12Z")

</div>

Hallo zusammen. In Eurem Plugin Migration Guide ([http://wiki.shopware.de/Plugin-Migratio … 21a17.html](http://wiki.shopware.de/Plugin-Migration-Guide-von-3.5.x-auf-4.0%5C_detail%5C_862%5C_SESS-bc2f670b9ebcae26fd97a5716a221a17.html)) ist die Rede von einer „neuen Variante“ wie Hooks im System zu registrieren sind. Gilt dieses auch schon für Beta 2? Sämtliche Umsetzungen von Hooks (bspw. Zahlungsmodul von Klarna) nutzen die alte Variante, welche im Gegensatz zur neuen auch tadellos funktioniert. ` function blaBlub() { $this-\>subscribeHook( 'Shopware\_Controllers\_Frontend\_Account::savePaymentAction::before', 'myPaymentAction' ); // ... } public function myPaymentAction(Enlight\_Hook\_HookArgs $args) { // ... } ` Sollte das obenstehende schon in der Beta2 vom 17.7. funktionieren?

---

<div class="post-metadata">

**Author:** ![fdehn](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/fdehn/32/86_2.png) [@fdehn](https://forum.shopware.com/u/fdehn)\
**Post date:** [25. Juli 2012 um 09:21 UTC](https://forum.shopware.com/t/problem-mit-hooks/7834/2 "2012-07-25T09:21:55Z")

</div>

[quote=“fdehn”] ` function blaBlub() { $this-\>subscribeHook( 'Shopware\_Controllers\_Frontend\_Account::savePaymentAction::before', 'myPaymentAction' ); // ... } public function myPaymentAction(Enlight\_Hook\_HookArgs $args) { // ... } ` [/quote] Passend hierzu eine Frage zum “Hooken” des Controllers Shopware\_Controllers\_Frontend\_Account und der Methode savePaymentAction: Anhand des Controllernamens setzt Enlight offensichtlich aufgrund der Konventionen automatisch ein/e View bzw. Template mit folgendem Pfad: frontend/account/save\_payment.tpl. Im von mir (auf alte Weise) überschriebenen Controller bzw. Methode wirft Enlight einen Fehler aufgrund eines nicht vorhandenen Templates (ist auch nicht vorhanden). Die originäre Methode (bzw. der Controller) bindet das selbe (nicht vorhandene Template) ein, hier wird aber kein Fehler geworfen. Hat jemand einen Tip, wie ich dieses Verhalten umgehe, ohne ein entsprechendes Template zur Verfügung zu stellen? Die von mir überschriebene Methode soll nichts darstellen, nur übergebene Parameter speichern.

---

<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:** [25. Juli 2012 um 09:49 UTC](https://forum.shopware.com/t/problem-mit-hooks/7834/3 "2012-07-25T09:49:36Z")

</div>

Hi, was machst du denn da genau in diesem Hook? In der originalen Action macht er ja eine Umleitung auf den Account, wodurch der kein Template mehr benötigt. `$this-\>redirect(array('controller'=\>$target, 'action'=\>'index', 'success'=\>'payment')); ` Heiner

---

<div class="post-metadata">

**Author:** ![fdehn](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/fdehn/32/86_2.png) [@fdehn](https://forum.shopware.com/u/fdehn)\
**Post date:** [25. Juli 2012 um 09:54 UTC](https://forum.shopware.com/t/problem-mit-hooks/7834/4 "2012-07-25T09:54:08Z")

</div>

Ich möchte bspw. eigens angelegte Felder bei einer Zahlart validieren und anschließend in eigenen Tabellen speichern… Ist es möglich, den originären Controller (also das Standardverhalten des Controllers) zu initialisieren (aufzurufen)?

---

<div class="post-metadata">

**Author:** ![fdehn](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/fdehn/32/86_2.png) [@fdehn](https://forum.shopware.com/u/fdehn)\
**Post date:** [25. Juli 2012 um 13:33 UTC](https://forum.shopware.com/t/problem-mit-hooks/7834/5 "2012-07-25T13:33:59Z")

</div>

Mein Hook wird wunderbar ausgeführt, ich kann aus diesem auch jedwede Aktion triggern die ich haben mag… letztlich will ich aber nur erreichen, dass vor dem Abspeichern der Zahlart eine Validierung von Parametern erfolgt. Sind diese erfolgreich validiert, so soll im Code einfach fortgefahren werden. Wenn die Validierung fehlschlägt, so wird meine Logik entsprechend darauf reagieren. Mir scheint, dass der per Hook erweiterte Controller (bzw er und seine Methode Shopware\_Controllers\_Frontend\_Account::savePaymentAction) trotz Enlight\_Hook\_HookHandler::TypeBefore nicht mehr ausgeführt wird. In Shopware 3.5.4 und neuer funktioniert(e) mein Ansatz bisher tadellos!
