Closed denisschafer closed 4 years ago
We deliberately didn't use a class to minimize runtime overhead; functions are entirely adequate here, and easier to then share with other bridge libraries, too.
This library isn't intended as a be-all-end-all, so I don't think adding configurability to it is necessary. You're free (and encouraged) to add your own autoload file via composer.json in your application that calls the functions in this package to wire up additional relationships or settings.
For the specific case of Platform.sh Dedicated, file a ticket with the support team to rename the relationship if it doesn't match the library. It's easy enough for them to change (I verified with them), and it should match this anyway.
Ok thanks for the answer, we'll manage on our own repo
This PR allows users of the lib to change the database and mongodb keys used in mapping. In my company we are using platformsh entreprise and we have several databases and users mapped in the PLATFORM_RELATIONSHIPS and we have some ugly hacks to injects the correct values into the environment vairiables by reading the correct entry in the relationship on a per application basis.
I've encapsulated the functions into a class and created a nice way for other users to override the ways the database key is feed by extending the new class and overriding the method initdbRelationshipNames().
Unit tests are presents and backward compatibility is assured by the file platformsh-flex-env-backward-compatible.php which proxies the old functions to the new class.