- 🇫🇮Finland merilainen
This looks better now. Maybe it's a bit drastic change to move everything to Drupal state, because the only thing which might change in the remote is the
service_id
andservices
values. Now all other configuration needs to be added manually to each environment. - 🇫🇮Finland merilainen
Now the module seems to give an error when saving a provider:
The website encountered an unexpected error. Please try again later. TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 163 of modules/contrib/tmgmt_ilangl/src/ILangLTranslatorUi.php).
And the data looks like this:
in_array('ilangl', NULL) (Line: 163) Drupal\tmgmt_ilangl\ILangLTranslatorUi->validateConfigurationForm(Array, Object) (Line: 237) Drupal\tmgmt\Form\TranslatorForm->validateForm(Array, Object)
Seems that the values are saved to the Drupal state and it's possible to select the provider which the form fetches, so translations still work correctly.
I noticed the issue with saving after updating the module. Problem is, on the file ILangTranslatorUi.php it tries to fetch the providers with this:
$providers = $ilanglTranslator->getState('providers');
Then if the provider you are trying to save is not there, it tries to save it. The problem is, for saving the provider, it makes sure the provider is not already in that providers array, but $providers returns undefined when empty so the function crashes and the provider never gets saved in the state since the function crashes before. I made a small validation and seems to solve the saving issue.