Get the data to be serialized and assigned to the response document.

@param ServerRequestInterface $request
@param Document               $document
@return mixed
963253
protected function data(ServerRequestInterface $request, Document $document)
    {
        $postId = array_get($request->getQueryParams(), 'post');
        $actor = $request->getAttribute('actor');
        $file = array_get($request->getUploadedFiles(), 'image');

        return $this->bus->dispatch(
            new UploadImage($postId, $file, $actor)
        );
    }
133417
public function getDocument($document, $rootNode)
	{
		if ($rootNode == null)
		{
			$rootNode = "page";
		}
		return $this->_persistUtil->getDocument($document, $rootNode);
	}
166049
protected function getHashId(Document $document, $sm) 
	{
		$main = $sm->get('neobazaar.service.main');
		$documentRepository = $main->getDocumentEntityRepository();
		return $documentRepository->getEncryptedId($document->getDocumentId());
	}
810431
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
    {
        $operation = $this->getOperation($request);

        $arguments = [];
        foreach ($operation->getParameters() as $parameter) {
            $arguments[] = $request->getAttribute($parameter->getName());
        }

        $result = call_user_func_array($this->commands[$operation->getId()], $arguments);

        return $delegate->process($request->withAttribute(self::ATTRIBUTE, $result));
    }
73240
protected function _getData(ServerRequestInterface $request)
    {
        $fields = $this->_config['fields'];
        $body = $request->getParsedBody();

        $data = [];
        foreach ($fields as $key => $field) {
            if (!isset($body[$field])) {
                return null;
            }

            $value = $body[$field];
            if (!is_string($value) || !strlen($value)) {
                return null;
            }

            $data[$key] = $value;
        }

        return $data;
    }
614839
public function send(DocumentInterface $document)
    {
        $classDoc = get_class($document);
        $this->factory
            ->setBuilder($this->getBuilder($classDoc))
            ->setSender($this->getSender($classDoc));

        return $this->factory->send($document);
    }
291883
protected function documentToStream(AbstractDocument $document): StreamInterface
    {
        $encoded = json_encode($document->toArray());

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \RuntimeException('Encoding error: "' . json_last_error_msg() . '""');
        }

        $stream = fopen('php://memory', 'r+');

        fwrite($stream, $encoded);
        fseek($stream, 0);

        return new Stream($stream);
    }
1204213
public function getOriginalDocumentData($document)
    {
        $oid = spl_object_hash($document);
        if (isset($this->originalDocumentData[$oid])) {
            return $this->originalDocumentData[$oid];
        }
        return array();
    }
560436
public function getFieldValue($document, $field)
    {
        if ($document instanceof Proxy && $field !== $this->identifier && ! $document->__isInitialized()) {
            $document->__load();
        }

        return $this->reflFields[$field]->getValue($document);
    }
185664
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
    {
        $validator = (new DescriptionMessageValidator($this->getDescription($request), $this->parameterAssembler));

        $result = $validator->validateRequest($request, $this->getPath($request)->getPath());

        if (!$result->isValid()) {
            return Factory::createResponse(400)
                ->withBody(
                    $this->createStringStream(
                        $this->bodySerializer->serialize(['errors' => $result->getErrorMessages()])
                    )
                )
                ->withHeader('Content-Type', $this->bodySerializer->getContentType());
        }

        return $delegate->process($request);
    }
863673
protected function transcodeDataToDocument($document, $identifier)
    {
        if (!$document instanceof Document) {

            if (is_object($document)) {
                if (get_class($document) == 'stdClass') {
                    $document = (array) $document;
                } else {
                    if ($document instanceof \JsonSerializable) {
                        $document = json_encode($document);
                    } elseif (method_exists($document, 'toArray')) {
                        $document = $document->toArray();
                    } else {
                        throw new \LogicException(
                            'The given object representing a document value eihter have to implement the JsonSerializable'.
                            'interface or a toArray() method in order to be stored it in elasticsearch.',
                            AdaptorException::DATA_UNSERIALIZABLE
                        );
                    }
                }
            }

            $document = $this->decorator->normalizeValue($document);

            Assertion::notEmpty($document, 'The document data may not be empty.');

            $document = new Document($identifier, $document);
        }

        return $document;
    }
1161525
public function validateDocument($document, $charset = null) {
        $document = (string) $document;
        $charset  = $charset ?: $this->defaultCharset;
        $headers  = [
            'Content-Type' => $this->getContentTypeString(
                $this->getMimeTypeForParser($this->parser),
                $charset
            ),
        ];

        $response = $this->httpClient->request('POST', '', [
            'body' => $document,
            'headers' => $headers,
            'query' => [
                'out' => 'json',
                'parser' => $this->parser
            ],
        ]);

        try {
            $response = new Response($response);
        } catch (RequestException $e) {
            throw new ServerException($e->getMessage());
        }

        return $response;
    }
642465
protected function handleRequest(RequestInterface $request): RequestInterface
    {
        if ($request instanceof JsonApiRequest) {
            $document = $request->getDocument();
            $stream   = $this->documentToStream($document);

            return $request->withBody($stream);
        }

        return $request;
    }
702096
public function getXmlSigned(DocumentInterface $document)
    {
        $xml = $this->builder->build($document);

        $this->lastXml = $this->signer->signXml($xml);

        return $this->lastXml;
    }
408495
protected function getFromQuery(ServerRequestInterface $request)
    {
        $params = array_intersect_key($request->getQueryParams(), array_flip($this->getQueryKeys()));
        $regex  = '~^\/?' . $this->getRegEx() . '\b~';

        foreach ($params as $key => $value) {
            if ( preg_match($regex, $value, $matches) ) {
                if (isset($matches['language'])) {
                    return $matches['language'];
                } else {
                    throw new RuntimeException('The regular expression pattern is missing a named subpattern "language".');
                }
            }
        }
    }
442873
public function serializeDocument(DocumentInterface $document, bool $identifiersOnly = false): array
    {
        $result = [];

        if ($this->shouldContainData($document)) {
            $result['data'] = (!$document->shouldBeHandledAsCollection() && $document->data()->isEmpty()) ?
                null : $this->createData($document, $identifiersOnly);
        }

        if (!$document->metaInformation()->isEmpty()) {
            $result['meta'] = $document->metaInformation()->all();
        }

        if (!$document->links()->isEmpty()) {
            foreach ($document->links()->all() as $link) {
                $result['links'][$link->name()] = $this->serializeLink($link);
            }
        }

        if (!$document->included()->isEmpty()) {
            foreach ($document->included()->all() as $resource) {
                $result['included'][] = $this->serializeResource(
                    $resource,
                    false
                );
            }
        }

        if (!$document->errors()->isEmpty()) {
            foreach ($document->errors()->all() as $error) {
                $result['errors'][] = $this->serializeError($error);
            }
        }

        // informations about json api
        $result['jsonapi'] = [
            'version' => '1.0'
        ];

        return $result;
    }
941579
public function checkElementKey(ServerRequest $request, Response $response): Response
    {
        $elementKey = $request->getQueryParams()['key'];

        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
        $storageRepository = $objectManager->get(StorageRepository::class);

        $isAvailable = true;
        if ($storageRepository->loadElement('tt_content', $elementKey)) {
            $isAvailable = false;
        }

        return new JsonResponse(['isAvailable' => $isAvailable]);
    }