Create the download response.

@param  string $result

@access public
@return mixed
339789
public function createResponse($result)
	{
		return Response::make($result, 200, [
			'Content-Type'        => $this->getContentType(),
			'Content-Disposition' => sprintf('attachment; filename="%s"', $this->getFilename()),
		]);
	}
748213
protected function _makeResult(array $result) {
        return Result::make($result, $this->getClient())->setModelClass($this->_fullModelClass());
    }
1266000
public function sendResult($result)
    {
        if (@ob_get_length()) {
            @ob_end_clean();
        }
        if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) {
            header('Content-Type: application/json; charset=' . APP_CHARSET, true);
        } else {
            header('Content-Type: text/plain; charset=' . APP_CHARSET, true);
        }
        echo json_encode($result);
        die();
    }
1215960
public function encodeResult($result)
	{
		$string = $this->encoder->encodeResult($result);

		return $this->encrypt($string);
	}
507384
protected function response_data($result, $method, $url)
    {
        if (isset($result['$data'])) {
            if (is_array($result['$data'])) {
                return Resource::instance($result, $this);
            }
            return $result['$data'];
        }
        return null;
    }
809356
private function createJsonResponseIfNeeded(
        GetResponseEvent $event,
        $result
    ) {
        /**
         * Only flushes if exists AnnotationFlush as a controller annotations.
         */
        if ($this->returnJson) {
            if ($result instanceof Exception) {
                $this->status = $result instanceof HttpExceptionInterface
                    ? $result->getStatusCode()
                    : $this->defaultErrorStatus;

                $result = [
                    'code' => $result->getCode(),
                    'namespace' => get_class($result),
                    'message' => $result->getMessage(),
                ];
            }

            $response = JsonResponse::create(
                $result,
                $this->status,
                $this->headers
            );

            $event->setResponse($response);
        }
    }
166829
protected function exportLinks($result)
    {
        $extraLinkList = $this->doc->createElement('ul');
        $labelFormat = LocalizationUtility::translate('download-label-format-simple', 'Pazpar2');
        if (count($result['location']) > 1) {
            $labelFormat = LocalizationUtility::translate('download-label-format-all', 'Pazpar2');
        }

        if ($this->conf['showKVKLink'] == 1) {
            $this->appendInfoToContainer($this->KVKItem($result), $extraLinkList);
        }
        $this->appendExportItemsTo($result['location'], $labelFormat, $extraLinkList);
        // Separate submenus for individual locations not implemented in the PHP version.

        $exportLinks = null;
        if ($extraLinkList->hasChildNodes()) {
            $exportLinks = $this->doc->createElement('div');
            $exportLinks->setAttribute('class', 'pz2-extraLinks');
            $exportLinksLabel = $this->doc->createElement('span');
            $exportLinks->appendChild($exportLinksLabel);
            $exportLinksLabel->setAttribute('class', 'pz2-extraLinksLabel');
            $exportLinksLabel->appendChild($this->doc->createTextNode(LocalizationUtility::translate('mehr Links', 'Pazpar2')));
            $exportLinks->appendChild($extraLinkList);
        }

        return $exportLinks;
    }
204708
protected function collectionFromResult($result)
    {
        // If we have one result which is not an assoc array, make it the first element of an array for the
        // collectionFromResult function so we always return a collection from filter
        if ((bool) count(array_filter(array_keys($result), 'is_string'))) {
            $result = [$result];
        }

        $class = $this->class;
        $collection = [];

        foreach ($result as $r) {
            $collection[] = new $class($this->connection, $r);
        }

        return $collection;
    }
1160717
public function responseIsSuccessfullyWithContainScalarResult($result)
    {
        Assertions::assertEquals(200, $this->response->getStatusCode(), sprintf(
            'Response with error "%s"',
            $this->response->getBody()
        ));

        Assertions::assertTrue(is_null($this->response->getRpcErrorCode()), sprintf(
            'Response with error "%s"',
            $this->response->getBody()
        ));

        Assertions::assertEquals($result, $this->response->getRpcResult(), sprintf(
            'Result must be a contain "%s"',
            $result
        ));
    }
207599
public function postProcess($result)
    {
        // determine whether there is anything to process
        if (    is_null($result)
            ||  is_a($result, Collection::class) && $result->isEmpty()
        ) {
            return $result;
        }

        // check if there is anything to do process it through
        if ($this->postProcessors->isEmpty()) return $result;


        // for each Model, instantiate and apply the processors
        if (is_a($result, Collection::class)) {

            $result->transform(function ($model) {
                return $this->applyPostProcessorsToModel($model);
            });

        } elseif (is_a($result, AbstractPaginator::class)) {
            // result is paginate() result
            // do not apply postprocessing for now (how would we even do it?)
            return $result;

        } else {
            // result is a model
            $result = $this->applyPostProcessorsToModel($result);
        }

        return $result;
    }
1331717
public function getResponse($result)
    {
        $content = $result->getContent();

        if ($result->headers->get('content-type') == 'application/json'){
            $content = json_decode($result->getContent(),true);
        }

        return array(
          'type' => 'rpc',
          'tid' => $this->tid,
          'action' => $this->action,
          'method' => $this->method,
          'result' => $content
        );
    }
1072598
private function applyTransformersToResult(Result $result): Result
    {
        return empty($result->getSubresults())
            ? Result::create(
                $result->getQueryUUID(),
                $result->getTotalItems(),
                $result->getTotalHits(),
                $result->getAggregations(),
                $result->getSuggests(),
                $this
                    ->transformer
                    ->fromItems(
                        $result->getItems()
                    )
            )
            : Result::createMultiResult(
                array_map(function (Result $subresult) {
                    return $this->applyTransformersToResult($subresult);
                }, $result->getSubresults())
            );
    }
155786
public function create(Result $result)
    {
        $this->om->persist($result);
        $this->om->flush();

        return $result;
    }
959269
protected function build_records($result)
    {
        $url = $result['$url'];
        $parent_url = $url;
        if (false !== ($pos = strpos($url, '?'))) {
            $url = substr(0, $pos);
        }

        $url = '/'.trim($url, '/');
        foreach ($result['$data'] as $key => $record) {
            $record_url = $url;
            if (isset($record['id'])) {
                $record_url .= '/'.$record['id'];
            }
            self::$client_links[$record_url] = &self::$client_links[$parent_url];
            $result['$data'][$key] = new Record(array(
                '$url' => $record_url,
                '$data' => $record
            ));
        }

        return $result;
    }
521807
public function onResult(\pq\Result $result = null) {
		if ($result && $result->status != \pq\Result::TUPLES_OK) {
			return $result;
		}
		
		$rowset = $this->getRowsetPrototype();
		if (is_callable($rowset)) {
			return $rowset($result);
		} elseif ($rowset) {
			return new $rowset($this, $result);
		}
		
		return $result;
	}
426630
public function build(ResultSpec $result): string
    {
        $response = [];
        $units = $result->getResults();

        foreach ($units as $unit) {
            /** @var AbstractResult $unit */
            if ($unit instanceof Result) {
                /** @var Result $unit */
                $response[] = [
                    'jsonrpc' => '2.0',
                    'result' => $this->preBuild($unit->getResult()),
                    'id'     => $unit->getId()
                ];
            } elseif ($unit instanceof Error) {
                /** @var Error $unit */
                $baseException = $unit->getBaseException();
                $response[] = [
                    'jsonrpc' => '2.0',
                    'error' => [
                        'code'    => $baseException->getJsonRpcCode(),
                        'message' => $this->getErrorMessage($baseException->getJsonRpcCode()),
                        'data'    => $baseException->getJsonRpcData()
                    ],
                    'id' => $unit->getId()
                ];
            }
        }

        if (empty($response)) {
            return '';
        }

        if ($result->isSingleResult()) {
            return json_encode($response[0]);
        }

        return json_encode($response);
    }
579389
protected function response($method, $url, $data, $result)
    {
        if (!isset($result['$url'])) {
            $result['$url'] = $url;
        }
        if ($this->cache) {
            $this->cache->clear($result);
            if (strtolower($method) === 'get') {
                $this->cache->put($url, $data, $result);
            }
        }

        return $this->response_data($result, $method, $url);
    }