-
-
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
[Admin] Disable toggling of base currency #6354
[Admin] Disable toggling of base currency #6354
Conversation
NoResponseMate
commented
Oct 7, 2016
Q | A |
---|---|
Bug fix? | yes |
New feature? | yes |
BC breaks? | yes |
Related tickets | - |
License | MIT |
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.
We need to check if we can use form type extension instead.
{ | ||
parent::buildForm($builder, $options); | ||
|
||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) { |
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.
function(...)
-> function (...)
🎉
/** | ||
* @author Jan Góralski <jan.goralski@lakion.com> | ||
*/ | ||
class CannotDisableCurrency extends Constraint |
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.
final?
/** | ||
* @author Jan Góralski <jan.goralski@lakion.com> | ||
*/ | ||
class CannotDisableCurrencyValidator extends ConstraintValidator |
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.
final?
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function validate($currency, Constraint $constraint) |
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 assertion that $currency
is instance of CurrencyInterface
.
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function validate($currency, Constraint $constraint) |
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 assertion that $constraint
is instance of CannotDisableCurrency
.
if ($currency->getCode() !== $this->baseCurrency) { | ||
return; | ||
} | ||
if ($currency->isEnabled()) { |
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 above.
/** | ||
* @author Jan Góralski <jan.goralski@lakion.com> | ||
*/ | ||
class CurrencyType extends BaseCurrencyType |
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.
Btw. I guess we can achieve the same result by using form type extensions instead of custom type. It will be also a lot cleaner.
c31889c
to
9712adb
Compare
Scenario: | ||
Given the store operates on a single channel | ||
And it uses the "USD" currency by default | ||
And I want to edit this currency |
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.
When
?
9712adb
to
4fc11a0
Compare
4fc11a0
to
c3ab499
Compare
Thanks Jasiek! |