Skip to content

Commit

Permalink
Fix: Correct $vars for Merx::triggerHook
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasfabian committed Jul 8, 2020
1 parent 7a52a16 commit 8d64d9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
8 changes: 4 additions & 4 deletions src/merx.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 8d64d9f

Please sign in to comment.