public function getConnection(<CollectionInterface> model)
{
var service, connectionService, connection, dependencyInjector, entityName;
let service = "mongo";
let connectionService = this->_connectionServices;
if typeof connectionService == "array" {
let entityName = get_class(model);
/**
* Check if the model has a custom connection service
*/
if isset connectionService[entityName] {
let service = connectionService[entityName];
}
}
let dependencyInjector = this->_dependencyInjector;
if typeof dependencyInjector != "object" {
throw new Exception("A dependency injector container is required to obtain the services related to the ORM");
}
/**
* Request the connection service from the DI
*/
let connection = dependencyInjector->getShared(service);
if typeof connection != "object" {
throw new Exception("Invalid injected connection service");
}
return connection;
}
public function getConnectionService(<CollectionInterface> model) -> string
{
var service, entityName;
let service = "mongo";
let entityName = get_class(model);
if isset this->_connectionServices[entityName] {
let service = this->_connectionServices[entityName];
}
return service;
}
Can you please use a settable variable for the connection service name instead of a hard coded string like "mongo" .
Can you please use a settable variable for the connection service name instead of a hard coded string like "mongo" .