-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support only for offline payment methods #86
Support only for offline payment methods #86
Conversation
f7d2fba
to
0b44857
Compare
src/Entity/CreditMemoUnit.php
Outdated
'product_name' => $this->productName, | ||
'total' => $this->total, | ||
'taxes_total' => $this->taxesTotal, | ||
]); | ||
|
||
return ($serialized !== false) ? $serialized : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should throw an exception instead of silently returning an empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed 👍
} | ||
} | ||
|
||
return $paymentMethods; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big one, but you can get rid of that unset
and phpdoc by using array_filter
:
return array_filter(
$this->paymentMethodRepository->findEnabledForChannel($channel),
function (PaymentMethodInterface $paymentMethod): bool {
Assert::notNull($paymentMethod->getGatewayConfig());
return $paymentMethod->getGatewayConfig()->getFactoryName() === 'offline';
}
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea 👍
e1aca17
to
309420d
Compare
@@ -46,6 +47,7 @@ public function __invoke(Request $request): Response | |||
|
|||
$this->session->getFlashBag()->add('success', 'sylius_refund.units_successfully_refunded'); | |||
} catch (CommandDispatchException $exception) { | |||
Assert::notNull($exception->getPrevious()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Assert::notNull() may result in throwing unhandled InvalidArgumentException - what about simple and more user friendly solution:
if (null === $exception->getPrevious()) {
$this->session->getFlashBag()->add('error', 'sylius.ui.unexpected_error_occurred');
}
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, there will always be a previous exception, as it's done automatically and silencing it could make more harm than good 😄 I'd leave it as it is (without it PHPStan is not passing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok then 👍
309420d
to
a97c5f2
Compare
See PS in #85 description