src/ServiceContainer.php
public function get($id)
    {
        if (isset($this->aliases[$id])) {
            $id = $this->aliases[$id];
        }

        if (!isset($this->keys[$id])) {
            throw new NotFoundException(sprintf(
                'The service "%s" is not found',
                $id
            ));
        }

        if (isset($this->values[$id])) {
            return $this->values[$id];
        }

        if (! $this->keys[$id]) {
            if (isset($this->factories[$id])) {
                return $this->createFromFactory($this->factories[$id]);
            } else {
                return $this->createFromDefinition($this->definition[$id]);
            }
        }

        if (isset($this->factories[$id])) {
            $service = $this->createFromFactory($this->factories[$id]);
            unset($this->factories[$id]);
        } else {
            $service = $this->createFromDefinition($this->definition[$id]);
            unset($this->definition[$id]);
        }

        $this->values[$id] = $service;
        $this->immutable[$id] = true;
        return $service;
    }
public function get($id)
    {
        if (isset($this->aliases[$id])) {
            $id = $this->aliases[$id];
        }

        if (!isset($this->keys[$id])) {
            throw new NotFoundException(sprintf(
                'The service "%s" is not found',
                $id
            ));
        }

        if (isset($this->values[$id])) {
            return $this->values[$id];
        }

        if (! $this->keys[$id]) {
            if (isset($this->factories[$id])) {
                return $this->createFromFactory($this->factories[$id]);
            } else {
                return $this->createFromDefinition($this->definition[$id]);
            }
        }

        if (isset($this->factories[$id])) {
            $service = $this->createFromFactory($this->factories[$id]);
            unset($this->factories[$id]);
        } else {
            $service = $this->createFromDefinition($this->definition[$id]);
            unset($this->definition[$id]);
        }

        $this->values[$id] = $service;
        $this->immutable[$id] = true;
        return $service;
    }
public function get ( $ id ) { if ( isset ( $ this -> aliases [ $ id ] ) ) { $ id = $ this -> aliases [ $ id ] ; } if ( ! isset ( $ this -> keys [ $ id ] ) ) { throw new NotFoundException ( sprintf ( 'The service "%s" is not found' , $ id ) ) ; } if ( isset ( $ this -> values [ $ id ] ) ) { return $ this -> values [ $ id ] ; } if ( ! $ this -> keys [ $ id ] ) { if ( isset ( $ this -> factories [ $ id ] ) ) { return $ this -> createFromFactory ( $ this -> factories [ $ id ] ) ; } else { return $ this -> createFromDefinition ( $ this -> definition [ $ id ] ) ; } } if ( isset ( $ this -> factories [ $ id ] ) ) { $ service = $ this -> createFromFactory ( $ this -> factories [ $ id ] ) ; unset ( $ this -> factories [ $ id ] ) ; } else { $ service = $ this -> createFromDefinition ( $ this -> definition [ $ id ] ) ; unset ( $ this -> definition [ $ id ] ) ; } $ this -> values [ $ id ] = $ service ; $ this -> immutable [ $ id ] = true ; return $ service ; }
Get entry of the container by its identifier.

@param string $id Identifier of the service.
@return mixed Entry of the container.
@throws NotFoundException If service not exist in container.
Get entry of the container by its identifier .