public function get($name, array $parameters = [])
    {
        // Shared services are preserved through whole request
        if (isset($this->shared[$name])) {
            return $this->shared[$name];
        }

        if (!$this->has($name)) {
            throw new NotFoundException('No definition found for service "' . $name . '".');
        }

        $definition = $this->definitions[$name];

        // Alias is a link to another definition
        if (isset($definition['alias'])) {
            return $this->get($definition['alias']);
        }

        // "Init" directive is a function that returns instance of service
        if (isset($definition['init'])) {
            $service_class = call_user_func($definition['init'], $this, $parameters);

            if ($service_class === false) {
                throw new NotFoundException('"Init" directive for service "' . $name . '" did not produced any object.');
            }
        } else {
            $arguments = [];

            // Array of arguments which are given to constructor method
            if (isset($definition['arguments'])) {
                $arguments = $this->resolveArrayOfArguments($definition['arguments'], $parameters);
            }

            // Service is made by static method
            if (isset($definition['static'])) {
                $service_class = call_user_func_array([$definition['class'], $definition['static']], $arguments);

                if ($service_class === false) {
                    throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.');
                }
            } else {
                // Service is made by normal constructor
                try {
                    $reflection_class = new \ReflectionClass($definition['class']);
                } catch (\ReflectionException $e) {
                    throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.');
                }

                $service_class = $reflection_class->newInstanceArgs($arguments);
            }
        }

        // "After" directive is a function that is called after instantiation of service object
        if (isset($definition['after'])) {
            call_user_func($definition['after'], $this, $service_class, $parameters);
        }

        // Preserve shared service
        if (isset($definition['shared']) && $definition['shared'] === true) {
            $this->shared[$name] = $service_class;
        }

        return $service_class;
    }
public function get($name, array $parameters = [])
    {
        // Shared services are preserved through whole request
        if (isset($this->shared[$name])) {
            return $this->shared[$name];
        }

        if (!$this->has($name)) {
            throw new NotFoundException('No definition found for service "' . $name . '".');
        }

        $definition = $this->definitions[$name];

        // Alias is a link to another definition
        if (isset($definition['alias'])) {
            return $this->get($definition['alias']);
        }

        // "Init" directive is a function that returns instance of service
        if (isset($definition['init'])) {
            $service_class = call_user_func($definition['init'], $this, $parameters);

            if ($service_class === false) {
                throw new NotFoundException('"Init" directive for service "' . $name . '" did not produced any object.');
            }
        } else {
            $arguments = [];

            // Array of arguments which are given to constructor method
            if (isset($definition['arguments'])) {
                $arguments = $this->resolveArrayOfArguments($definition['arguments'], $parameters);
            }

            // Service is made by static method
            if (isset($definition['static'])) {
                $service_class = call_user_func_array([$definition['class'], $definition['static']], $arguments);

                if ($service_class === false) {
                    throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.');
                }
            } else {
                // Service is made by normal constructor
                try {
                    $reflection_class = new \ReflectionClass($definition['class']);
                } catch (\ReflectionException $e) {
                    throw new NotFoundException('Class "' . $definition['class'] . '" for service "' . $name . '" was not found.');
                }

                $service_class = $reflection_class->newInstanceArgs($arguments);
            }
        }

        // "After" directive is a function that is called after instantiation of service object
        if (isset($definition['after'])) {
            call_user_func($definition['after'], $this, $service_class, $parameters);
        }

        // Preserve shared service
        if (isset($definition['shared']) && $definition['shared'] === true) {
            $this->shared[$name] = $service_class;
        }

        return $service_class;
    }
public function get ( $ name , array $ parameters = [ ] ) { // Shared services are preserved through whole request if ( isset ( $ this -> shared [ $ name ] ) ) { return $ this -> shared [ $ name ] ; } if ( ! $ this -> has ( $ name ) ) { throw new NotFoundException ( 'No definition found for service "' . $ name . '".' ) ; } $ definition = $ this -> definitions [ $ name ] ; // Alias is a link to another definition if ( isset ( $ definition [ 'alias' ] ) ) { return $ this -> get ( $ definition [ 'alias' ] ) ; } // "Init" directive is a function that returns instance of service if ( isset ( $ definition [ 'init' ] ) ) { $ service_class = call_user_func ( $ definition [ 'init' ] , $ this , $ parameters ) ; if ( $ service_class === false ) { throw new NotFoundException ( '"Init" directive for service "' . $ name . '" did not produced any object.' ) ; } } else { $ arguments = [ ] ; // Array of arguments which are given to constructor method if ( isset ( $ definition [ 'arguments' ] ) ) { $ arguments = $ this -> resolveArrayOfArguments ( $ definition [ 'arguments' ] , $ parameters ) ; } // Service is made by static method if ( isset ( $ definition [ 'static' ] ) ) { $ service_class = call_user_func_array ( [ $ definition [ 'class' ] , $ definition [ 'static' ] ] , $ arguments ) ; if ( $ service_class === false ) { throw new NotFoundException ( 'Class "' . $ definition [ 'class' ] . '" for service "' . $ name . '" was not found.' ) ; } } else { // Service is made by normal constructor try { $ reflection_class = new \ ReflectionClass ( $ definition [ 'class' ] ) ; } catch ( \ ReflectionException $ e ) { throw new NotFoundException ( 'Class "' . $ definition [ 'class' ] . '" for service "' . $ name . '" was not found.' ) ; } $ service_class = $ reflection_class -> newInstanceArgs ( $ arguments ) ; } } // "After" directive is a function that is called after instantiation of service object if ( isset ( $ definition [ 'after' ] ) ) { call_user_func ( $ definition [ 'after' ] , $ this , $ service_class , $ parameters ) ; } // Preserve shared service if ( isset ( $ definition [ 'shared' ] ) && $ definition [ 'shared' ] === true ) { $ this -> shared [ $ name ] = $ service_class ; } return $ service_class ; }
get
Get service instance.

@param string $name
@param array $parameters
@return mixed
@access public
@uses \ReflectionClass
@throws NotFoundException
get Get service instance .