Пример #1
0
 /**
  * @param ContextInterface $context
  * @param \Iterator $iterator
  */
 protected function setPredefinedFilters(ContextInterface $context, \Iterator $iterator)
 {
     $filters = null;
     if ($context->hasOption('filters')) {
         $filters = $context->getOption('filters');
         $context->removeOption('filters');
     }
     $complexFilters = null;
     if ($context->hasOption('complex_filters')) {
         $complexFilters = $context->getOption('complex_filters');
         $context->removeOption('complex_filters');
     }
     if ($filters || $complexFilters) {
         if ($iterator instanceof PredefinedFiltersAwareInterface) {
             $predefinedFilters = new BatchFilterBag((array) $filters, (array) $complexFilters);
             $iterator->setPredefinedFiltersBag($predefinedFilters);
         } else {
             throw new \LogicException('Iterator does not support predefined filters');
         }
     }
 }