Skip to content
Snippets Groups Projects
Commit d028402e authored by Dimitris Bozelos's avatar Dimitris Bozelos
Browse files

Issue #3409349 Support overriding the entity client

parent 84a1e185
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,13 @@ use KrystalCode\Api\Session\SessionManagerInterface; ...@@ -42,7 +42,13 @@ use KrystalCode\Api\Session\SessionManagerInterface;
* - odata: (array, optional) An array containing `select` and `expand` items to * - odata: (array, optional) An array containing `select` and `expand` items to
* add to the corresponding OData clauses. Currenlty only supported by the * add to the corresponding OData clauses. Currenlty only supported by the
* `importList` client method. OData filters are not supported yet. * `importList` client method. OData filters are not supported yet.
* - client_class: (string, optional) The fully qualified name of the client
* class to instantiate. This may be useful in case it is necessary to
* extend/override the client provided by this module; it allows doing so
* without having to write a factory as well. The client class must be
* compatible with the instantiation done in this factory.
* *
* @see \Drupal\entity_sync_odata\EntitySync\Api\EntityClient::__construct()
* @see \KrystalCode\Api\Session\SessionManagerInterface::setOptions() * @see \KrystalCode\Api\Session\SessionManagerInterface::setOptions()
* phpcs:disable * phpcs:disable
* @I Add client adapter for integrations that do not require authentication * @I Add client adapter for integrations that do not require authentication
...@@ -84,6 +90,14 @@ class EntityClientFactory implements ProviderClientFactoryInterface { ...@@ -84,6 +90,14 @@ class EntityClientFactory implements ProviderClientFactoryInterface {
} }
} }
if (isset($parameters['client_class'])) {
return new $parameters['client_class'](
$this->getSessionManager($parameters),
$parameters['entity_type'],
$parameters['odata'] ?? []
);
}
return new EntityClient( return new EntityClient(
$this->getSessionManager($parameters), $this->getSessionManager($parameters),
$parameters['entity_type'], $parameters['entity_type'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment