/** * {@inheritdoc} */ public function compare(FieldDescriptorInterface $other) { if (!$other instanceof self) { return false; } return $this->getEntityName() === $other->getEntityName() && $this->getFieldName() === $other->getFieldName(); }
/** * Function that finds all IDs of entities that match the * search criteria. * * @return array */ protected function findIdsByGivenCriteria() { $select = null; if (null !== $this->idField) { $select = $this->idField->getSelect(); } $subQueryBuilder = $this->createSubQueryBuilder($select); if ($this->limit != null) { $subQueryBuilder->setMaxResults($this->limit)->setFirstResult($this->limit * ($this->page - 1)); } foreach ($this->sortFields as $index => $sortField) { $subQueryBuilder->addSelect($sortField->getSelect() . ' AS ' . $sortField->getName()); } $this->assignSortFields($subQueryBuilder); $ids = $subQueryBuilder->getQuery()->getArrayResult(); // if no results are found - return if (count($ids) < 1) { return []; } $ids = array_map(function ($array) { return $array['id']; }, $ids); return $ids; }
/** * Returns index of given FieldDescriptor in given array of descriptors. * If no match is found, false will be returned. * * @param FieldDescriptorInterface $fieldDescriptor * @param FieldDescriptorInterface[] $fieldDescriptors * * @return bool|int|string */ protected function retrieveIndexOfFieldDescriptor(FieldDescriptorInterface $fieldDescriptor, array $fieldDescriptors) { foreach ($fieldDescriptors as $index => $other) { if ($fieldDescriptor->compare($other)) { return $index; } } return false; }