phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.78k stars 1.96k forks source link

CollectionManager hard coded "mongo" string #11725

Closed bkirova closed 8 years ago

bkirova commented 8 years ago
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" .

sergeyklay commented 8 years ago

@AlexKomrakov Could you please deal with this?

sergeyklay commented 8 years ago

Fixed in 2.1.x branch