Processes LDAP search results and constructs their model instances.

@param resource $results

@return Collection|array
482343
public function process($results)
    {
        // Normalize entries. Get entries returns false on failure.
        // We'll always want an array in this situation.
        $entries = $this->connection->getEntries($results) ?: [];

        if ($this->builder->isRaw()) {
            // If the builder is asking for a raw
            // LDAP result, we can return here.
            return $entries;
        }

        $models = [];

        if (Arr::has($entries, 'count')) {
            for ($i = 0; $i < $entries['count']; $i++) {
                // We'll go through each entry and construct a new
                // model instance with the raw LDAP attributes.
                $models[] = $this->newLdapEntry($entries[$i]);
            }
        }

        // If the query contains paginated results, we'll return them here.
        if ($this->builder->isPaginated()) {
            return $models;
        }

        // If the query is requested to be sorted, we'll perform
        // that here and return the resulting collection.
        if ($this->builder->isSorted()) {
            return $this->processSort($models);
        }

        // Otherwise, we'll return a regular unsorted collection.
        return $this->newCollection($models);
    }
799395
public function getFirstEntry($searchResults)
    {
        if ($this->suppressErrors) {
            return @ldap_first_entry($this->getConnection(), $searchResults);
        }

        return ldap_first_entry($this->getConnection(), $searchResults);
    }
518390
public function processColumnListing($results)
	{
		$mapping = function ($r) {
			$r = (object) $r;

			return $r->name;
		};

		return array_map($mapping, $results);
	}
614642
public function buildMultiResultSet(Response $response, array $searches): ResultSet
    {
        $resultSets = $this->buildResultSets($response, $searches);

        return new ResultSet($response, $resultSets);
    }
722861
protected function runGroupSort($results)
    {
        if (!$results instanceof QueryResultset) {
            return $results;
        }
        $grouped = [];
        $resultTaxOrders = [];
        foreach ($results as $result) {
            $taxGroup = null;
            foreach ($result->getTaxonomy() as $taxonomy) {
                if (in_array($taxonomy->getTaxonomytype(), $result->getTaxonomy()->getGroupingTaxonomies())) {
                    $taxGroup = $taxonomy->getSlug();
                    $taxOrder = $taxonomy->getSortorder();
                    $resultTaxOrders[$result->getId()] = $taxOrder;
                }
            }
            if ($taxGroup !== null) {
                $grouped[$taxGroup][] = $result;
            } else {
                $grouped['ungrouped'][] = $result;
            }
        }

        if (!count($grouped)) {
            return $results;
        }
        if (isset($taxGroup) && $taxGroup !== null) {
            foreach ($grouped as &$group) {
                usort($group, function ($a, $b) use ($resultTaxOrders) {
                    $aOrder = isset($resultTaxOrders[$a->getId()]) ? $resultTaxOrders[$a->getId()] : 0;
                    $bOrder = isset($resultTaxOrders[$b->getId()]) ? $resultTaxOrders[$b->getId()] : 0;

                    return $aOrder - $bOrder;
                });
            }
        }

        return call_user_func_array('array_merge', $grouped);
    }
787700
public function processColumnListing($results)
    {
        $mapping = function ($r) {
            $r = (object) $r;

            return $r->column_name;
        };

        return array_map($mapping, $results);
    }
381452
private function iteratorFromResults(array $results)
    {
        $values = [];

        foreach ($results as $item) {
            $entry = new IndexEntry();

            $entry->indexKey  = key($item);
            $entry->objectKey = reset($item);

            $values[] = $entry;
        }

        return new ArrayIterator($values);
    }
842746
protected function _makeResult(array $result) {
        return Result::make($result, $this->getClient())->setModelClass($this->_fullModelClassNamePattern());
    }
523752
private function buildResults($results)
    {
        return array_map(function ($result) {
            $coordinates = $result['geometry']['location'];
            $data = [
                'address' => $result['formatted_address'],
                'latitude' => $coordinates['lat'],
                'longitude' => $coordinates['lng'],
                'place_id' => $result['place_id'],
                'types' => $result['types'],
                'address_components' => $this->buildAddressComponents($result)
            ];

            if (isset($result['geometry']['bounds'])) {
                $bounds = $result['geometry']['bounds'];
                $data['bounds'] = [
                    'northeast' => [
                        'latitude' => $bounds['northeast']['lat'],
                        'longitude' => $bounds['northeast']['lng'],
                    ],
                    'southwest' => [
                        'latitude' => $bounds['southwest']['lat'],
                        'longitude' => $bounds['southwest']['lng'],
                    ]
                ];
            }

            return $data;
        }, $results);
    }
36944
public function build(array $results, array $eagerLoads)
    {
        // Make a list of all primary key of the current result set. This will
        // allow us to group all polymorphic operations by type, then put
        // back every object in the intended order.
        $primaryKeyColumn = $this->entityMap->getKeyName();
        $ids = array_map(function ($row) use ($primaryKeyColumn) {
            return $row[$primaryKeyColumn];
        }, $results);

        $results = array_combine($ids, $results);

        // Make a list of types appearing within this result set.
        $discriminatorColumn = $this->entityMap->getDiscriminatorColumn();
        $types = array_unique(array_pluck($results, $discriminatorColumn));

        // We'll split the result set by type that will make it easier to deal
        // with.
        $entities = [];

        foreach ($types as $type) {
            $this->mappers[$type] = $this->getMapperForType($type);

            $resultsByType[$type] = array_filter($results, function (array $row) use ($type, $discriminatorColumn) {
                return $row[$discriminatorColumn] === $type;
            });

            $entities = $entities + $this->buildResultsForType($resultsByType[$type], $type, $eagerLoads);
        }

        return array_map(function ($id) use ($entities) {
            return $entities[$id];
        }, $ids);
    }
368064
protected function processResult(array $results)
    {
        foreach ($results as $key => $entity) {

            if (!empty($entity['data'])) {

                $entity['data'] = $this->decorator->denormalizeValue($entity['data']);
                $results[$key] = $entity;
            }
        }

        return $results;
    }
1340111
public function process(SearchResultSet $resultSet)
    {
        if (!$resultSet instanceof SearchResultSet) {
            return $resultSet;
        }

        $resultSet = $this->parseSpellCheckingResponseIntoObjects($resultSet);
        $resultSet = $this->parseSortingIntoObjects($resultSet);

        // here we can reconstitute other domain objects from the solr response
        $resultSet = $this->parseFacetsIntoObjects($resultSet);

        return $resultSet;
    }
837232
protected function transform($results, $processed)
    {
        if (isset($this->transformer) && class_exists('Yajra\\DataTables\\Transformers\\FractalTransformer')) {
            return app('datatables.transformer')->transform(
                $results,
                $this->transformer,
                $this->serializer ?? null
            );
        }

        return Helper::transform($processed);
    }
570750
protected function buildDictionary(Collection $results)
    {
        $dictionary = [];

        foreach ($results as $result) {
            $dictionary[$result[static::THROUGH_KEY]] = $result;

            unset($result[static::THROUGH_KEY]);
        }

        return $dictionary;
    }
589494
public function setResults($results)
    {
        // hydrate model
        foreach ($results as $entry) {
            /** @var EntityDataModel $model */
            $model = $this->getModel();
            $model->setEntityManager($this->getEntityManager());

            // check for json
            if (array_key_exists('[json]', $entry)) {
                $entry = json_decode($entry['[json]']);
            }

            $model = $this->populate($entry, $model);

            $this->collection[] = $model;
        }

        $this->setCount(count($this->collection));

        return $this;
    }
1223902
private function getFormattedResults(&$results) {
    return implode('', array(
        $this->getReportInfo($results),
        $this->getPaginationInfo($results),
        $this->getProfileInformation($results),
        $this->getQueryParameters($results),
        $this->getColumnHeaders($results),
        $this->getTotalsForAllResults($results),
        $this->getRows($results)
    ));
    
  }
600278
protected function getResultTable($results)
    {
        $resultSet = 1;
        $resultTable     = \MUtil_Html::create()->array();
        foreach ($results as $result) {
            if (is_string($result)) {
                $this->addMessage($result);
            } else {
                $resultRow = $resultTable->echo($result, sprintf($this->_('Result set %s.'), $resultSet++));
                $resultRow->class = 'browser';
            }
        }
        return $resultTable;
    }