protected function load($service)
    {
        $sol = isset($this->loaded[$service]['loader'])
            ? $this->loaded[$service]['loader']
            : null;

        // Load by calling a function
        if (is_callable($sol)) {
            try {
                $this->active[$service] = $sol();
            } catch (\Exception $e) {
                throw new \Exception(
                    "CDI could not load service '$service'."
                    . "Failed in the callback that instantiates the service. "
                    . $e->getMessage()
                );
            }
        } elseif (is_object($sol)) {
            // Load by pre-instantiated object
            $this->active[$service] = $sol;
        } elseif (is_string($sol)) {
            // Load by creating a new object from class-string
            $this->active[$service] = new $sol();
        } else {
            throw new Exception("CDI could not load service '$service'. It is unknown how to load it.");
        }

        $this->$service = $this->active[$service];
        return $this->active[$service];
    }
protected function load($service)
    {
        $sol = isset($this->loaded[$service]['loader'])
            ? $this->loaded[$service]['loader']
            : null;

        // Load by calling a function
        if (is_callable($sol)) {
            try {
                $this->active[$service] = $sol();
            } catch (\Exception $e) {
                throw new \Exception(
                    "CDI could not load service '$service'."
                    . "Failed in the callback that instantiates the service. "
                    . $e->getMessage()
                );
            }
        } elseif (is_object($sol)) {
            // Load by pre-instantiated object
            $this->active[$service] = $sol;
        } elseif (is_string($sol)) {
            // Load by creating a new object from class-string
            $this->active[$service] = new $sol();
        } else {
            throw new Exception("CDI could not load service '$service'. It is unknown how to load it.");
        }

        $this->$service = $this->active[$service];
        return $this->active[$service];
    }
protected function load ( $ service ) { $ sol = isset ( $ this -> loaded [ $ service ] [ 'loader' ] ) ? $ this -> loaded [ $ service ] [ 'loader' ] : null ; // Load by calling a function if ( is_callable ( $ sol ) ) { try { $ this -> active [ $ service ] = $ sol ( ) ; } catch ( \ Exception $ e ) { throw new \ Exception ( "CDI could not load service '$service'." . "Failed in the callback that instantiates the service. " . $ e -> getMessage ( ) ) ; } } elseif ( is_object ( $ sol ) ) { // Load by pre-instantiated object $ this -> active [ $ service ] = $ sol ; } elseif ( is_string ( $ sol ) ) { // Load by creating a new object from class-string $ this -> active [ $ service ] = new $ sol ( ) ; } else { throw new Exception ( "CDI could not load service '$service'. It is unknown how to load it." ) ; } $ this -> $ service = $ this -> active [ $ service ] ; return $ this -> active [ $ service ] ; }
Lazy load a service object and create an instance of it.

@param string $service as a service label, naming this service.

@return object as instance of the service object.
@throws Exception when service could not be loaded.
Lazy load a service object and create an instance of it .