Wraps all DAO result entities in model instances

@param array $result
@return array
967027
protected function wrapAll(array $result): array
    {
        $modelName = $this->getModelName();

        foreach ($result as &$entity) {
            $entity = $this->createModel($modelName, $entity);
        }

        return $result;
    }
567530
protected function createModelFromDatabaseResult(array $result)
    {
        $model = $this->getEmptyModel();

        foreach ($result as $key => $value) {
            if ($key === $this->idProperty) {
                $model->setIdRaw($value);
            }

            $model->setPropertyRaw($key, StringUtil::deserialize($value));
        }

        return $model;
    }
654860
public function addData(array $result): array
    {
        if ($result['tableName'] === 'sys_redirect' && isset($result['processedTca']['columns']['source_host'])) {
            $domains = $this->getHosts();
            foreach ($domains as $domain) {
                $result['processedTca']['columns']['source_host']['config']['valuePicker']['items'][] =
                    [
                        $domain,
                        $domain,
                    ];
            }
        }
        return $result;
    }
1099352
protected function makeObjects(IResult $result) {

        // TODO: Prefer to return existing instances from IdentityMap

        $instances = [];
        while ($row = $result->fetchRow(ARRAY_ASSOC)) {
            $instances[] = PersistableObject::populateNew($this->entityClass, $row);
        }
        return $instances;
    }
219297
protected function transformResultsToRoutes(array $results)
    {
        $routes = [];
        foreach ($results as $result) {
            $name = $result['route'];
            if (array_key_exists($name, $routes)) {
                /** @var Route $route */
                $route = $routes[$name];
                $paths = $route->getOption('i18n_paths');
                $paths[$result['locale']] = $result['path'];
                $route->setOption('i18n_paths', $paths);
            } else {
                $route = new Route($result['path']);
                if (!array_key_exists($result['controller'], $this->config['controllers'])) {
                    throw new \RuntimeException(sprintf('Undefined controller "%s".', $result['controller']));
                }
                $paths = [$result['locale'] => $result['path']];
                $route
                    ->setDefault('_controller', $this->config['controllers'][$result['controller']]['value'])
                    ->setMethods(['GET'])
                    ->setOption('i18n_paths', $paths)
                ;
                $routes[$name] = $route;
            }
        }
        // TODO check that i18n_paths are set for all locales ?
        return $routes;
    }
171687
private function processResult(array $result)
    {
        $this->checkResponseStatus($result['http_code']);

        // Get decoded response data
        $responseArr = json_decode($result['response'], true);

        $this->checkJsonError();

        return $responseArr;
    }
492559
public function parseResult($results)
    {
        $simpleDataTable = $results->getDataTable()->toSimpleObject();

        foreach ($simpleDataTable->cols as $col) {
            $cols[] = $col['label'];
        }

        foreach ($simpleDataTable->rows as $row) {
            foreach ($row['c'] as $key => $value) {
                $rowData[$cols[$key]] = $value['v'];
            }

            $rows[] = $rowData;

            unset($rowData);
        }

        return [
            'cols' => $cols,
            'rows' => $rows,
        ];
    }
316601
public static function extractResultOutput(array $result)
    {
        // extracting result only make sense when error is `null`.
        assert(static::isResultSuccessful($result) === true && $result[static::REPLY_ERRORS_INFO] === null);

        $value = $result[static::REPLY_SUCCESS_VALUE];

        return $value;
    }
574145
protected function buildDictionary(array $results)
    {
        $dictionary = [];

        // First we will create a dictionary of models keyed by the foreign key of the
        // relationship as this will allow us to quickly access all of the related
        // models without having to do nested looping which will be quite slow.
        foreach ($results as $result) {
            $dictionary[$result->{$this->firstKey}][] = $result;
        }

        return $dictionary;
    }
176052
public function buildResult($result)
    {
        $chatMembers = [];

        foreach ($result as $item) {
            $chatMembers[] = new ChatMember($item);
        }

        return $chatMembers;
    }
149756
protected function from_db_records(array $results) {
        $entityfactory = $this->get_entity_factory();

        return array_map(function(array $result) use ($entityfactory) {
            [
                'discussion' => $discussion,
                'firstpost' => $firstpost,
                'firstpostauthor' => $firstpostauthor,
                'latestpostauthor' => $latestpostauthor,
            ] = $result;
            return $entityfactory->get_discussion_summary_from_stdclass(
                $discussion,
                $firstpost,
                $firstpostauthor,
                $latestpostauthor
            );
        }, $results);
    }
508435
public function mergeTranslatedFields($result) {
        if (!isset($result->{self::I18N_MODEL_BINDING_ALIAS})) {
            return;
        }
        $translationRecordList = $result->{self::I18N_MODEL_BINDING_ALIAS};
        if ($translationRecordList instanceof Zend_Db_Table_Rowset_Abstract) {
            $translationRecordList = $translationRecordList->toArray();
        }
        $translatedFields = array();
        $allLocales = Garp_I18n::getLocales();
        foreach ($this->_translatableFields as $translatableField) {
            // provide default values
            foreach ($allLocales as $locale) {
                $translatedFields[$translatableField][$locale] = null;
            }
            foreach ($translationRecordList as $translationRecord) {
                $lang = $translationRecord[self::LANG_COLUMN];
                $translatedFields[$translatableField][$lang]
                    = $translationRecord[$translatableField];
            }
            $result->setVirtual($translatableField, $translatedFields[$translatableField]);
                //$lang] = $translationRecord[$translatableField];
        }
        // We now have a $translatedFields array like this:
        // array(
        //   "name" => array(
        //     "nl" => "Schaap",
        //     "en" => "Sheep"
        //   )
        // )
        //$result->setFromArray($translatedFields);
        unset($result->{self::I18N_MODEL_BINDING_ALIAS});
    }
1099998
protected function toEntityCollection($result)
    {
        switch (true) {

            // already a collection ?
            case is_object($result) && is_subclass_of($result, $this->collectionClass) :
                $collection = $result;
                break;

            // already a collection ?
            case $result instanceof Collection :
                $collection = new $this->collectionClass($result->toArray());
                break;

            // simple related entity ?
            case is_object($result) && is_subclass_of($result, $this->entityClass) :
                $collection = new $this->collectionClass(array($result));
                break;

            // simple array ?
            case is_array($result) :
                $collection = new $this->collectionClass($result);
                break;

            default:
                $collection = new $this->collectionClass();
                break;
        }

        if (is_callable(array($this, 'onLoad'))) {
            @trigger_error(
                sprintf('%s::onLoad() call is deprecated and will be removed in 2.0. Make "%s" invokable instead if you require to custom every "%s" loaded by ORM.',
                    static::class,
                    static::class,
                    $this->entityClass
                ),
                E_USER_DEPRECATED
            );

            return $this->onLoad($collection);
        }

        return $collection;
    }
1037895
protected function prepareList($result, array $options)
    {
        $handlers = $this->getHandlers();

        if (empty($result['data'])) {
            $result['data'] = $handlers;
        } else {
            $result['data'] = array_replace_recursive($handlers, $result['data']);
        }

        foreach ($result['data'] as $handler_id => &$handler) {

            if (!empty($options['active']) && empty($handler['status'])) {
                unset($result['data'][$handler_id]);
                continue;
            }

            try {
                $handler['data'] = (array) $this->callHandler($handler_id);
            } catch (Exception $ex) {
                $handler['data'] = array();
            }
        }

        gplcart_array_sort($result['data']);
        return $result;
    }
786059
public function buildResult($result)
    {
        $updates = [];

        foreach ($result as $updateData) {
            $update = new Update($updateData);
            $updates[] = $update;
            $this->lastUpdateId = max($this->lastUpdateId, $update->updateId);
        }

        return $updates;
    }
820996
protected function from_db_records(array $results) {
        $entityfactory = $this->get_entity_factory();

        return array_map(function(array $result) use ($entityfactory) {
            ['record' => $record] = $result;
            return $entityfactory->get_post_from_stdclass($record);
        }, $results);
    }
738752
private function processHitResultsRecurse($results, $prefix=null) {
        if(!is_array($results)) {
            return [$prefix => $results];
        }

        $ret = [];
        foreach($results as $key=>$result) {
            // Flatten arrays.
            $sub_prefix = is_null($prefix) ? $key:"$prefix.$key";
            $ret = array_merge($ret, $this->processHitResultsRecurse($result, $sub_prefix));
        }
        return $ret;
    }