Cascade\Config\Loader\ClassLoader\Resolver\ConstructorResolver::resolve PHP Method

resolve() public method

Resolve options against constructor args
public resolve ( array $options ) : array
$options array Array of option values. Expected array looks like: array( 'someParam' => 'def', 'someOtherParam' => 'sdsad' )
return array Array of resolved ordered args
    public function resolve(array $options)
    {
        $reflectedClassName = $this->reflected->getName();
        // We check if that constructor has been configured before and is in the registry
        if (!isset(self::$resolvers[$reflectedClassName])) {
            self::$resolvers[$reflectedClassName] = new OptionsResolver();
            $this->configureOptions(self::$resolvers[$reflectedClassName]);
        }
        return $this->hashToArgsArray(self::$resolvers[$reflectedClassName]->resolve($options));
    }

Usage Example

 /**
  * Resolve options and returns them into 2 buckets:
  *   - constructor options and
  *   - extra options
  * Extra options are those that are not in the contructor. The constructor arguments determine
  * what goes into which bucket
  *
  * @return array array of constructorOptions and extraOptions
  */
 private function resolveOptions()
 {
     $constructorResolver = new ConstructorResolver($this->reflected);
     // Contructor options are only the ones matching the contructor args' names
     $constructorOptions = array_intersect_key($this->rawOptions, $constructorResolver->getConstructorArgs());
     // Extra options are everything else than contructor options
     $extraOptions = array_diff_key($this->rawOptions, $constructorOptions);
     $extraOptionsResolver = new ExtraOptionsResolver($this->reflected, array_keys($extraOptions));
     return array($constructorResolver->resolve($constructorOptions), $extraOptionsResolver->resolve($extraOptions, $this));
 }
All Usage Examples Of Cascade\Config\Loader\ClassLoader\Resolver\ConstructorResolver::resolve