src/xPDO/xPDO.php
public function getService($name, $class= '', $path= '', $params= array ()) {
        $service= null;
        if (!$this->services->has($name) || !is_object($this->services->get($name))) {
            if (empty ($class) && isset ($this->config[$name . '.class'])) {
                $class= $this->config[$name . '.class'];
            } elseif (empty ($class)) {
                $class= $name;
            }
            $className= $this->loadClass($class, $path, false, true);
            if (!empty($className)) {
                $service = new $className($this, $params);
                if ($service) {
                    $this->services->add($name, $service);
                    $this->$name= $this->services->get($name);
                }
            }
        }
        if ($this->services->has($name)) {
            $service = $this->services->get($name);
        } else {
            if ($this->getDebug() === true) {
                $this->log(xPDO::LOG_LEVEL_DEBUG, "Problem getting service {$name}, instance of class {$class}, from path {$path}, with params " . print_r($params, true));
            } else {
                $this->log(xPDO::LOG_LEVEL_ERROR, "Problem getting service {$name}, instance of class {$class}, from path {$path}");
            }
        }
        return $service;
    }
public function getService($name, $class= '', $path= '', $params= array ()) {
        $service= null;
        if (!$this->services->has($name) || !is_object($this->services->get($name))) {
            if (empty ($class) && isset ($this->config[$name . '.class'])) {
                $class= $this->config[$name . '.class'];
            } elseif (empty ($class)) {
                $class= $name;
            }
            $className= $this->loadClass($class, $path, false, true);
            if (!empty($className)) {
                $service = new $className($this, $params);
                if ($service) {
                    $this->services->add($name, $service);
                    $this->$name= $this->services->get($name);
                }
            }
        }
        if ($this->services->has($name)) {
            $service = $this->services->get($name);
        } else {
            if ($this->getDebug() === true) {
                $this->log(xPDO::LOG_LEVEL_DEBUG, "Problem getting service {$name}, instance of class {$class}, from path {$path}, with params " . print_r($params, true));
            } else {
                $this->log(xPDO::LOG_LEVEL_ERROR, "Problem getting service {$name}, instance of class {$class}, from path {$path}");
            }
        }
        return $service;
    }
public function getService ( $ name , $ class = '' , $ path = '' , $ params = array ( ) ) { $ service = null ; if ( ! $ this -> services -> has ( $ name ) || ! is_object ( $ this -> services -> get ( $ name ) ) ) { if ( empty ( $ class ) && isset ( $ this -> config [ $ name . '.class' ] ) ) { $ class = $ this -> config [ $ name . '.class' ] ; } elseif ( empty ( $ class ) ) { $ class = $ name ; } $ className = $ this -> loadClass ( $ class , $ path , false , true ) ; if ( ! empty ( $ className ) ) { $ service = new $ className ( $ this , $ params ) ; if ( $ service ) { $ this -> services -> add ( $ name , $ service ) ; $ this -> $ name = $ this -> services -> get ( $ name ) ; } } } if ( $ this -> services -> has ( $ name ) ) { $ service = $ this -> services -> get ( $ name ) ; } else { if ( $ this -> getDebug ( ) === true ) { $ this -> log ( xPDO :: LOG_LEVEL_DEBUG , "Problem getting service {$name}, instance of class {$class}, from path {$path}, with params " . print_r ( $ params , true ) ) ; } else { $ this -> log ( xPDO :: LOG_LEVEL_ERROR , "Problem getting service {$name}, instance of class {$class}, from path {$path}" ) ; } } return $ service ; }
Load and return a named service class instance.

@deprecated Use the service/DI container to access services. Will be removed in 3.1.

@param string $name The variable name of the instance.
@param string $class The service class name.
@param string $path An optional root path to search for the class.
@param array $params An array of optional params to pass to the service
class constructor.
@return object|null A reference to the service class instance or null if
it could not be loaded.
Load and return a named service class instance .