Open alessandromarotta opened 5 years ago
I found this workaround:
public function updateCMSFields(FieldList $fields) {
[...]
$locale_query = SQLSelect::create();
$locale_query->setFrom('member');
$locale_query->addWhere('ID = ' . $this->owner->ID);
$locale_query->setSelect('Locale');
$this->owner->setField("Locale", $locale_query->execute()->value());
}
Yes, I think you've found a naming conflict between Fluent and framework. There's not much that can be done, other than ensuring that the methods Fluent adds to owner classes via its extensions are called getFluentLocale()
instead of getLocale()
. This would be a breaking change unfortunately, so would be unlikely to be done and released quickly.
At a slightly higher level, this problem would also exist in framework for all extensions being added to an owner object - e.g. three extensions all add the same method getFooBar()
, you can't easily define which one should run and in which order.
I'm glad you've found a workaround. I think for now the best approach would be to update the documentation to include a note for this problem. If you'd be keen to make a pull request to do so, that'd be great!
Affected Version
tractorcow/silverstripe-fluent 4.2.0 with silverstripe-framework 4.3.3
Description
I need to translate a Member field ("About Me") with Fluent but this overrides the "Locale" value of the Member, which means that it will change the "Interface Language" of the CMS.
amwMemberPrivateExtension.php
myExtensions.yml
I think this is a bug, but how could I solve this problem with a workaround?
Thank you!