-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Shop][Payment] Prevent selecting payment method not assigned to channel #5689
[Shop][Payment] Prevent selecting payment method not assigned to channel #5689
Conversation
tuka217
commented
Aug 3, 2016
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Related tickets | - |
License | MIT |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function findEnabledForChannel(ChannelInterface $channel) |
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.
Why won't we just use $channel->getPaymentMethods()
collection? It implements Doctrine\Common\Collections\Selectable
, so:
$channel->getPaymentsMethods()->matching(new Criteria(new Comparison('enabled', Comparison::EQ, true)))
Should work even faster (we won't need to hydrate all the payment methods only to pass them to another query).
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.
Then we would not need this custom repository, we can use it directly in the resolver or implement on the model - see http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-associations.html#filtering-collections.
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.
Of course the typehint is oversimplified now, it's either ArrayCollection
(if created manually) or PersistentCollection
(if hydrated by Doctrine), but both of them implements Collection
and Selectable
.
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.
Yups :)
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.
In current implementation it cannot be done in this way.
0fe018d
to
1ecf79a
Compare
8593dbc
to
322fbae
Compare
use Sylius\Component\Core\Model\ChannelInterface; | ||
use Sylius\Component\Resource\Repository\RepositoryInterface; | ||
use Sylius\Component\Payment\Repository\PaymentMethodRepositoryInterface as BasePaymentMethodRepositoryInterface; | ||
/** |
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.
Missing blank line
322fbae
to
e6dc95f
Compare
…signed to channel
e6dc95f
to
33d8cd8
Compare
…toryInterface [CoreBundle] Add implementation for method from PaymentMethodRepositoryInterface Add implementation of scenario
33d8cd8
to
0e3af9e
Compare
Thank you Ania! :) |
[Shop][Payment] Prevent selecting payment method not assigned to channel