REST clients currently require a database connection in their constructor. However, the connection is only used when a client has query limitations (::ensureQueryLimits()) set to keep track of request dates. If a client would like to handle limitations differently (ie. not using a database), then having a connection can become useless... and it is already useless for clients with no limitations. It complicates tests as the connection needs to be mocked.
Furthermore, not only REST clients may need to test limits between queries (or REST clients not derived from the base RestClient).
Remove the connection from the ExternalEntityType class properties and from its constructor. Use Drupal database service in ::ensureQueryLimits().
Move the ::ensureQueryLimits() method to a new trait "QueryLimitationTrait" that could be reused by other storage client plugins (not derived from the current RestClient base).
Please provide opinions on that change thanks.
None.
REST clients won't need a connection by default. Some existing REST clients (based on RestClient class) that have their own constructors will need to be updated.
None.
Active
3.0
Code