/**
  * Add a grid type.
  *
  * @param GridTypeInterface $type
  *
  * @return $this
  */
 public function addType(GridTypeInterface $type)
 {
     $name = $type->getName();
     if ($this->hasType($name)) {
         throw new TypeAlreadyExistsException($name);
     }
     $this->types[$name] = $type;
     return $this;
 }
 /**
  * Returns the options resolved.
  *
  * @param GridTypeInterface $type
  * @param Source            $source
  * @param array             $options
  *
  * @return array
  */
 private function resolveOptions(GridTypeInterface $type, Source $source = null, array $options = array())
 {
     $resolver = new OptionsResolver();
     $type->configureOptions($resolver);
     if (null != $source && !isset($options['source'])) {
         $options['source'] = $source;
     }
     $options = $resolver->resolve($options);
     return $options;
 }