/**
  * Create base dataset for configuration.
  *
  * @throws TargetPrototypeNotFoundException If prototype is requested, but can not be located.
  * @param ActiveConfigurationInterface $config
  * @return QueryBuilder
  */
 public function createQueryBuilder(ActiveConfigurationInterface $config)
 {
     $target = $config->getTarget();
     $queryBuilder = $this->getTargetQueryBuilder($target);
     if ($target->isPrototyped()) {
         $prototype = $this->getTargetPrototype($target, $config->getTargetPrototype());
         if (!$prototype) {
             throw new TargetPrototypeNotFoundException($prototype->getName());
         }
         $queryBuilder->filterByColumn("prototype", $prototype);
     }
     return $queryBuilder;
 }
 /**
  * Filter a result set for a given configuration.
  *
  * @param ActiveConfigurationInterface $config
  * @param array $data
  * @return array
  */
 public static function filter(ActiveConfigurationInterface $config, array $data)
 {
     $data = new ArrayCollection($data);
     $filters = $config->getFields();
     $filterOptions = $config->getOriginalConfig()->getFields();
     $fields = array_keys($filters);
     $criteria = Criteria::create();
     foreach ($fields as $field) {
         foreach ($filters[$field] as $key => $filter) {
             $resolver = new OptionsResolver();
             $filter->configureOptions($resolver);
             $options = $filter->resolveOptions($resolver, $filterOptions[$field][$key]->getOptions());
             $filter->filter($criteria, $config->getField($field), $options);
         }
     }
     return $data->matching($criteria)->getValues();
 }