protected function resolve($type, $name, $registry, array $args = array())
    {
        if($registry instanceof \Closure)
            return call_user_func_array($registry->bindTo($this), $args);

        if(is_string($registry)) {
            if($type == 'service')
                return $this->instantiate($registry);
            else
                return $this->instantiate($registry, $args);
        }

        // assume index 0 as class name
        if(is_array($registry))
        {
            $class = $registry[0];

            $arguments = array();

            // argument passed
            if(isset($registry[1]))
            {
                // the second element isn't an array
                if(!is_array($registry[1]))
                    throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Second value for array based ['.$name.'] registry must be an array');

                foreach($registry[1] as $arg)
                {
                    // if isn't string. allow only string.
                    if(!is_string($arg))
                        throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Argument for array based ['.$name.'] registry must be string');

                    if($arg = $this->tokenResolve($arg))
                        $arguments[] = $arg;
                }
            }

            // merge with the one passed
            $arguments = array_merge($arguments, $args);

            return $this->instantiate($class, $arguments);
        }

        throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Unable to resolve the ['.$name.'] registry');
    }
protected function resolve($type, $name, $registry, array $args = array())
    {
        if($registry instanceof \Closure)
            return call_user_func_array($registry->bindTo($this), $args);

        if(is_string($registry)) {
            if($type == 'service')
                return $this->instantiate($registry);
            else
                return $this->instantiate($registry, $args);
        }

        // assume index 0 as class name
        if(is_array($registry))
        {
            $class = $registry[0];

            $arguments = array();

            // argument passed
            if(isset($registry[1]))
            {
                // the second element isn't an array
                if(!is_array($registry[1]))
                    throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Second value for array based ['.$name.'] registry must be an array');

                foreach($registry[1] as $arg)
                {
                    // if isn't string. allow only string.
                    if(!is_string($arg))
                        throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Argument for array based ['.$name.'] registry must be string');

                    if($arg = $this->tokenResolve($arg))
                        $arguments[] = $arg;
                }
            }

            // merge with the one passed
            $arguments = array_merge($arguments, $args);

            return $this->instantiate($class, $arguments);
        }

        throw new \Exedra\Exception\InvalidArgumentException('['.get_class($this).'] Unable to resolve the ['.$name.'] registry');
    }
protected function resolve ( $ type , $ name , $ registry , array $ args = array ( ) ) { if ( $ registry instanceof \ Closure ) return call_user_func_array ( $ registry -> bindTo ( $ this ) , $ args ) ; if ( is_string ( $ registry ) ) { if ( $ type == 'service' ) return $ this -> instantiate ( $ registry ) ; else return $ this -> instantiate ( $ registry , $ args ) ; } // assume index 0 as class name if ( is_array ( $ registry ) ) { $ class = $ registry [ 0 ] ; $ arguments = array ( ) ; // argument passed if ( isset ( $ registry [ 1 ] ) ) { // the second element isn't an array if ( ! is_array ( $ registry [ 1 ] ) ) throw new \ Exedra \ Exception \ InvalidArgumentException ( '[' . get_class ( $ this ) . '] Second value for array based [' . $ name . '] registry must be an array' ) ; foreach ( $ registry [ 1 ] as $ arg ) { // if isn't string. allow only string. if ( ! is_string ( $ arg ) ) throw new \ Exedra \ Exception \ InvalidArgumentException ( '[' . get_class ( $ this ) . '] Argument for array based [' . $ name . '] registry must be string' ) ; if ( $ arg = $ this -> tokenResolve ( $ arg ) ) $ arguments [ ] = $ arg ; } } // merge with the one passed $ arguments = array_merge ( $ arguments , $ args ) ; return $ this -> instantiate ( $ class , $ arguments ) ; } throw new \ Exedra \ Exception \ InvalidArgumentException ( '[' . get_class ( $ this ) . '] Unable to resolve the [' . $ name . '] registry' ) ; }
Actual resolve the given type of registry
@param $name
@param $registry
@param array $args
@return mixed
@throws \Exedra\Exception\InvalidArgumentException
Actual resolve the given type of registry