*/ class ResourceIterator extends \core_kernel_classes_ResourceIterator implements ServiceLocatorAwareInterface { use ServiceLocatorAwareTrait; private $classessUsedInCriteria = []; /** @var QueryInterface */ private $criteria; /** * @inheritdoc * @param array $criteria */ public function __construct($classes, QueryInterface $criteria = null) { parent::__construct($classes); $this->criteria = $criteria; } /** * Load resources from storage * * @param core_kernel_classes_Class $class * @param integer $offset * @return core_kernel_classes_Resource[] */ protected function loadResources(core_kernel_classes_Class $class, $offset) { $search = $this->getServiceLocator()->get(ComplexSearchService::SERVICE_ID); $queryBuilder = $search->query()->setLimit(self::CACHE_SIZE)->setOffset($offset); $criteria = $search->searchType($queryBuilder, $class->getUri(), false); if ($this->criteria !== null) { foreach ($this->criteria->getStoredQueryCriteria() as $storedQueryCriterion) { $criteria->addCriterion( $storedQueryCriterion->getName(), $storedQueryCriterion->getOperator(), $storedQueryCriterion->getValue() ); } } $queryBuilder = $queryBuilder->setCriteria($criteria); return $search->getGateway()->search($queryBuilder); } }