protected function autoResolve($name, $params)
    {
        try {
            $reflection = new \ReflectionClass($name);
            if ($reflection->isInstantiable()) {
                $construct = $reflection->getConstructor();
                if ($construct === null) {
                    $object = new $name;
                } else {
                    $dependencies = $this->getDependencies($construct->getParameters());
                    $object = $reflection->newInstanceArgs($dependencies);
                }

                try {
                    $method = $reflection->getMethod('setParams');
                    $method->invokeArgs($object, $params);

                // Do nothing. This method may very well not exist.
                } catch (\ReflectionException $e) {}

                // Allow a list of methods to be executed.
                if (isset($params['methods'])) {
                    foreach ($params['methods'] as $method) {
                        $method = $reflection->getMethod($method);
                        $method->invokeArgs($object, $this->getDependencies($method->getParameters()));
                    }
                }

                // If this single method is invoked, its results will be returned.
                if (isset($params['invoke'])) {
                    $method = $params['invoke'];
                    $method = $reflection->getMethod($method);
                    return $method->invokeArgs($object, $this->getDependencies($method->getParameters()));
                }

                return $object;
            }
        } catch (\ReflectionException $e) {
            throw new \LogicException("Unable to resolve '{$name}'");
        }
    }
protected function autoResolve($name, $params)
    {
        try {
            $reflection = new \ReflectionClass($name);
            if ($reflection->isInstantiable()) {
                $construct = $reflection->getConstructor();
                if ($construct === null) {
                    $object = new $name;
                } else {
                    $dependencies = $this->getDependencies($construct->getParameters());
                    $object = $reflection->newInstanceArgs($dependencies);
                }

                try {
                    $method = $reflection->getMethod('setParams');
                    $method->invokeArgs($object, $params);

                // Do nothing. This method may very well not exist.
                } catch (\ReflectionException $e) {}

                // Allow a list of methods to be executed.
                if (isset($params['methods'])) {
                    foreach ($params['methods'] as $method) {
                        $method = $reflection->getMethod($method);
                        $method->invokeArgs($object, $this->getDependencies($method->getParameters()));
                    }
                }

                // If this single method is invoked, its results will be returned.
                if (isset($params['invoke'])) {
                    $method = $params['invoke'];
                    $method = $reflection->getMethod($method);
                    return $method->invokeArgs($object, $this->getDependencies($method->getParameters()));
                }

                return $object;
            }
        } catch (\ReflectionException $e) {
            throw new \LogicException("Unable to resolve '{$name}'");
        }
    }
protected function autoResolve ( $ name , $ params ) { try { $ reflection = new \ ReflectionClass ( $ name ) ; if ( $ reflection -> isInstantiable ( ) ) { $ construct = $ reflection -> getConstructor ( ) ; if ( $ construct === null ) { $ object = new $ name ; } else { $ dependencies = $ this -> getDependencies ( $ construct -> getParameters ( ) ) ; $ object = $ reflection -> newInstanceArgs ( $ dependencies ) ; } try { $ method = $ reflection -> getMethod ( 'setParams' ) ; $ method -> invokeArgs ( $ object , $ params ) ; // Do nothing. This method may very well not exist. } catch ( \ ReflectionException $ e ) { } // Allow a list of methods to be executed. if ( isset ( $ params [ 'methods' ] ) ) { foreach ( $ params [ 'methods' ] as $ method ) { $ method = $ reflection -> getMethod ( $ method ) ; $ method -> invokeArgs ( $ object , $ this -> getDependencies ( $ method -> getParameters ( ) ) ) ; } } // If this single method is invoked, its results will be returned. if ( isset ( $ params [ 'invoke' ] ) ) { $ method = $ params [ 'invoke' ] ; $ method = $ reflection -> getMethod ( $ method ) ; return $ method -> invokeArgs ( $ object , $ this -> getDependencies ( $ method -> getParameters ( ) ) ) ; } return $ object ; } } catch ( \ ReflectionException $ e ) { throw new \ LogicException ( "Unable to resolve '{$name}'" ) ; } }
Method to do the heavy lifting in relation to reolution of assets.

In most cases this method returns an asset (object) or null. It can however be
coherced into returning the results of a call to a method on the asst (object)
itself by passing a method name along within the $params array indexed by "invoke".

@param string $name
@param array @params Any extra parameters.
Method to do the heavy lifting in relation to reolution of assets .