From 8d64d9f2e8f31df1749ec9cb303fa86325e0b67d Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Wed, 8 Jul 2020 16:48:10 +0200 Subject: [PATCH] Fix: Correct $vars for Merx::triggerHook --- src/cart.php | 2 +- src/merx.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cart.php b/src/cart.php index 9729326..8d2bd95 100644 --- a/src/cart.php +++ b/src/cart.php @@ -19,7 +19,7 @@ public function __construct(array $data = []) $data = $kirby->session()->get($this->sessionName); } parent::__construct($data); - Merx::triggerHook('ww.merx.cart', [$this]); + Merx::triggerHook('ww.merx.cart', ['cart' => $this]); $this->save(); } diff --git a/src/merx.php b/src/merx.php index 963ccbc..8f93b1e 100644 --- a/src/merx.php +++ b/src/merx.php @@ -186,7 +186,7 @@ public function initializePayment(array $data): string $cart = $this->cart; // run hook - Merx::triggerHook('ww.merx.initializePayment:before', [$data, $cart]); + Merx::triggerHook('ww.merx.initializePayment:before', compact('data', 'cart')); // check cart if ($cart->count() <= 0) { @@ -248,7 +248,7 @@ public function initializePayment(array $data): string kirby()->session()->set('ww.merx.virtualOrderPage', $virtualOrderPage->toArray()); // run hook - Merx::triggerHook('ww.merx.initializePayment:after', [$virtualOrderPage, $redirect]); + Merx::triggerHook('ww.merx.initializePayment:after', compact('virtualOrderPage', 'redirect')); return $redirect; } catch (\Exception $ex) { @@ -280,7 +280,7 @@ public function completePayment(array $data = []): OrderPage $virtualOrderPage = $this->getVirtualOrderPageFromSession(); $gateway = $this->getGateway($virtualOrderPage->paymentMethod()->toString()); - Merx::triggerHook('ww.merx.completePayment:before', [$virtualOrderPage, $gateway, $data]); + Merx::triggerHook('ww.merx.completePayment:before', compact('virtualOrderPage', 'gateway', 'data')); if (is_callable($gateway['completePayment'])) { $gateway['completePayment']($virtualOrderPage, $data); @@ -297,7 +297,7 @@ public function completePayment(array $data = []): OrderPage $this->cart->delete(); kirby()->session()->remove('ww.merx.virtualOrderPage'); - Merx::triggerHook('ww.merx.completePayment:after', [$orderPage]); + Merx::triggerHook('ww.merx.completePayment:after', compact('orderPage')); return $orderPage; } catch (\Exception $ex) {