A very lightweight handler for getting information about already indexed files from a Solr response.

@param SolrObject $responsedoc A Solr response document
@return stdClass[] An array of objects that contain the basic information for file processing.
510446
protected function convert_file_results($responsedoc) {
        if (!$docs = $responsedoc->response->docs) {
            return array();
        }

        $out = array();

        foreach ($docs as $doc) {
            // Copy the bare minimim needed info.
            $result = new \stdClass();
            $result->id = $doc->id;
            $result->modified = document::import_time_from_engine($doc->modified);
            $result->title = $doc->title;
            $result->solr_fileid = $doc->solr_fileid;
            $result->solr_filecontenthash = $doc->solr_filecontenthash;
            $result->solr_fileindexstatus = $doc->solr_fileindexstatus;
            $out[] = $result;
        }

        return $out;
    }
1069219
private function buildExtensions(SimpleXMLElement $phpDocumentor): array
    {
        if ((array) $phpDocumentor->parser === []) {
            return $this->extensions;
        }

        if ((array) $phpDocumentor->parser->extensions === []) {
            return $this->extensions;
        }

        return $this->buildArrayFromNode($phpDocumentor->parser->extensions);
    }
961258
@SuppressWarnings("unchecked")
    public static final List<Map<String, Object>> getDocuments(Map<String, Object> result) {
        if (MapUtils.isNotEmpty(result) && result.containsKey(RESPONSE_KEY)) {
            Map<String, Object> response = (Map<String, Object>)result.get(RESPONSE_KEY);
            if (MapUtils.isNotEmpty(response) && response.containsKey(DOCUMENTS_KEY)) {
                return  (List<Map<String, Object>>)response.get(DOCUMENTS_KEY);
            }
        }

        return null;
    }
965981
private function processDocument(Document $document, $exposedPrefix = '')
    {
        $result = [];
        foreach ($document->getFields() as $field) {
            if ($field instanceof Field) {
                if ($field->getType() === 'extref') {
                    $result[] = $exposedPrefix.$field->getExposedName();
                }
            } elseif ($field instanceof ArrayField) {
                if ($field->getItemType() === 'extref') {
                    $result[] = $exposedPrefix.$field->getExposedName().'.0';
                }
            } elseif ($field instanceof EmbedOne) {
                $result = array_merge(
                    $result,
                    $this->processDocument(
                        $field->getDocument(),
                        $exposedPrefix.$field->getExposedName().'.'
                    )
                );
            } elseif ($field instanceof EmbedMany) {
                $result = array_merge(
                    $result,
                    $this->processDocument(
                        $field->getDocument(),
                        $exposedPrefix.$field->getExposedName().'.0.'
                    )
                );
            }
        }

        return $result;
    }
707989
protected function pathsArray(HttpServerDoc $doc) : array
    {
        $paths = [];
        foreach ($doc->getMethodList() as $method) {
            $operationDoc = $this->operationDocNormalizer->normalize($method);

            // As JSON-RPC use only one endpoint
            // and openApi does not handle multiple request definition for the same endpoint
            // => create a fake (but usable) endpoint by using method id and '/../'
            $openApiHttpEndpoint = sprintf(
                '/%s/..%s',
                str_replace('/', '-', $method->getIdentifier()),
                $doc->getEndpoint() ?? ''
            );

            $paths[$openApiHttpEndpoint] = ['post' => $operationDoc];
        }

        return $this->appendIfValueHaveSiblings('paths', $paths);
    }
1025557
protected function applyIndexPagePostProcessors($pageDocument)
    {
        if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPagePostProcessPageDocument'])) {
            return;
        }

        foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPagePostProcessPageDocument'] as $classReference) {
            $postProcessor = GeneralUtility::makeInstance($classReference);
            if (!$postProcessor instanceof PageDocumentPostProcessor) {
                throw new \UnexpectedValueException(get_class($pageDocument) . ' must implement interface ' . PageDocumentPostProcessor::class, 1397739154);
            }

            $postProcessor->postProcessPageDocument($pageDocument, $this->page);
        }
    }
892008
protected function getMetadataFromHeaders(Response $response) {
    $last_modified = \DateTime::createFromFormat(
        \DateTime::RFC1123,
        $response->getHeader('Last-Modified')[0]
    );

    // NonRDFSource's are considered files.  Everything else is a
    // directory.
    $type = 'dir';
    $links = Psr7\parse_header($response->getHeader('Link'));
    foreach ($links as $link) {
      if ($link['rel'] == 'type' && $link[0] == '<http://www.w3.org/ns/ldp#NonRDFSource>') {
        $type = 'file';
        break;
      }
    }

    $meta = [
      'type' => $type,
      'timestamp' => $last_modified->getTimestamp(),
    ];

    if ($type == 'file') {
      $meta['size'] = $response->getHeader('Content-Length')[0];
      $meta['mimetype'] = $response->getHeader('Content-Type')[0];
    }

    return $meta;
  }
1101460
protected function getMethodErrorsExternalSchemaList(ServerDoc $doc) : array
    {
        $list = [];
        foreach ($doc->getMethodList() as $method) {
            $list = array_merge(
                $list,
                $this->normalizeErrorList(
                    $method->getCustomErrorList(),
                    DefinitionRefResolver::CUSTOM_ERROR_DEFINITION_TYPE
                )
            );
        }

        return $list;
    }
607479
protected function docToArray(RpbSearchDoc $doc)
    {
        if ( ! $doc->hasFields()) {
            return [];
        }

        $values = [];

        foreach ($doc->fields as $pair) {
            $values[$pair->key][] = $pair->value;
        }

        return $values;
    }
372368
protected function extractMetaData(ResponseInterface $response)
    {
        $headers = $this->findMetaHeaders($response);

        if (!count($headers)) {
            return [];
        }

        $metaData = [];

        foreach ($headers as $header) {
            $metaData[$header] = $response->getHeaderLine($header);
        }

        return $metaData;
    }
857409
public function getMethods($entity)
    {
        $reflectionClass = new \ReflectionClass($entity);

        $methods = [];
        foreach ($reflectionClass->getMethods() as $method) {
            /** @var Field $annotation */
            $annotation = $this->reader->getMethodAnnotation($method, self::FIELD_CLASS);

            if ($annotation === null) {
                continue;
            }

            $annotation->value = $method->invoke($entity);
            
            if ($annotation->name == '') {
                throw new SolrMappingException(sprintf('Please configure a field-name for method "%s" with field-annotation in class "%s"', $method->getName(), get_class($entity)));
            }

            $methods[] = $annotation;
        }

        return $methods;
    }
1119904
public function getDocumentActualData(object $document) : array
    {
        $class      = $this->dm->getClassMetadata(get_class($document));
        $actualData = [];
        foreach ($class->reflFields as $name => $refProp) {
            $mapping = $class->fieldMappings[$name];
            // skip not saved fields
            if (isset($mapping['notSaved']) && $mapping['notSaved'] === true) {
                continue;
            }
            $value = $refProp->getValue($document);
            if ((isset($mapping['association']) && $mapping['type'] === 'many')
                && $value !== null && ! ($value instanceof PersistentCollectionInterface)) {
                // If $actualData[$name] is not a Collection then use an ArrayCollection.
                if (! $value instanceof Collection) {
                    $value = new ArrayCollection($value);
                }

                // Inject PersistentCollection
                $coll = $this->dm->getConfiguration()->getPersistentCollectionFactory()->create($this->dm, $mapping, $value);
                $coll->setOwner($document, $mapping);
                $coll->setDirty(! $value->isEmpty());
                $class->reflFields[$name]->setValue($document, $coll);
                $actualData[$name] = $coll;
            } else {
                $actualData[$name] = $value;
            }
        }
        return $actualData;
    }
652213
public function getProcessedResponse()
    {
        $_documentClass = $this->_documentClass;
        $_edgeClass = $this->_edgeClass;

        $response = $this->getResponse();
        switch ($this->_type) {
            case 'first':
                $json             = $response->getJson();
                if (!isset($json['error']) || $json['error'] === false) {
                    $options           = $this->getCursorOptions();
                    $options['_isNew'] = false;
                    $response          = $_documentClass::createFromArray($json['document'], $options);
                } else {
                    $response          = false;
                }
                break;
            case 'getdocument':
                $json              = $response->getJson();
                $options           = $this->getCursorOptions();
                $options['_isNew'] = false;
                $response          = $_documentClass::createFromArray($json, $options);
                break;
            case 'document':
                $json = $response->getJson();
                if (!isset($json['error']) || $json['error'] === false) {
                    $id       = $json[$_documentClass::ENTRY_ID];
                    $response = $id;
                }
                break;
            case 'getedge':
                $json              = $response->getJson();
                $options           = $this->getCursorOptions();
                $options['_isNew'] = false;
                $response          = $_edgeClass::createFromArray($json, $options);
                break;
            case 'edge':
                $json = $response->getJson();
                if (!isset($json['error']) || $json['error'] === false) {
                    $id       = $json[Edge::ENTRY_ID];
                    $response = $id;
                }
                break;
            case 'getedges':
                $json              = $response->getJson();
                $options           = $this->getCursorOptions();
                $options['_isNew'] = false;
                $response          = [];
                foreach ($json[EdgeHandler::ENTRY_EDGES] as $data) {
                    $response[] = $_edgeClass::createFromArray($data, $options);
                }
                break;
            case 'getcollection':
                $json     = $response->getJson();
                $response = Collection::createFromArray($json);
                break;
            case 'collection':
                $json = $response->getJson();
                if (!isset($json['error']) || $json['error'] === false) {
                    $id       = $json[Collection::ENTRY_ID];
                    $response = $id;
                }
                break;
            case 'cursor':
            case 'all':
            case 'by':
                $options          = $this->getCursorOptions();
                $options['isNew'] = false;

                $options  = array_merge(['_documentClass' => $this->_documentClass], $options);
                $response = new Cursor($this->_batch->getConnection(), $response->getJson(), $options);
                break;
            case 'remove':
                $json     = $response->getJson();
                $response = [
                    'removed' => $json['removed'],
                    'ignored' => $json['ignored']
                ];
                break;
                
            default:
                throw new ClientException('Could not determine response data type.');
                break;
        }

        return $response;
    }
1004660
protected function getMethodErrorArrayDoc(MethodDoc $method, array $extraErrorDefinitionIdRefList = []) : array
    {
        $self = $this;

        $errorDocList = array_merge(
            array_map(
                function ($errorRef) use ($self) {
                    $errorDoc = new ErrorDoc('', 0, null, null, $errorRef);
                    return [
                        '$ref' => $self->definitionRefResolver->getDefinitionRef(
                            $self->definitionRefResolver->getErrorDefinitionId(
                                $errorDoc,
                                DefinitionRefResolver::CUSTOM_ERROR_DEFINITION_TYPE
                            )
                        )
                    ];
                },
                $method->getGlobalErrorRefList()
            ),
            array_map(
                function (ErrorDoc $errorDoc) use ($self) {
                    return [
                        '$ref' => $self->definitionRefResolver->getDefinitionRef(
                            $self->definitionRefResolver->getErrorDefinitionId(
                                $errorDoc,
                                DefinitionRefResolver::CUSTOM_ERROR_DEFINITION_TYPE
                            )
                        )
                    ];
                },
                $method->getCustomErrorList()
            ),
            $extraErrorDefinitionIdRefList
        );

        if (count($errorDocList) > 0) {
            return ['oneOf' => $errorDocList];
        }

        return ['type' => 'object'];
    }
1077603
public static List<String> extractResponseDescription(JavadocComment jdoc){
		List<String> list = new ArrayList<>();
		list.addAll(extractDocAnnotation(DOC_RESPONSE_DESCRIPTION,jdoc));

		return list;
	}
631456
protected static function getBody(PsrResponse $response)
    {
        $stream = $response->getBody();
        if ($stream->getMetadata('wrapper_type') === 'plainfile') {
            return ['body' => '', 'file' => $stream->getMetadata('uri')];
        }
        if ($stream->getSize() === 0) {
            return ['body' => '', 'file' => false];
        }
        $stream->rewind();

        return ['body' => $stream->getContents(), 'file' => false];
    }
262375
public function normalize(MethodDoc $method) : array
    {
        $docTags = [];

        if (count($method->getTagList())) {
            $docTags['tags'] = $method->getTagList();
        }

        return [
                'summary' => sprintf('"%s" json-rpc method', $method->getMethodName()),
            ]
            + $this->getDescriptionDoc($method)
            + $docTags
            + [
                'operationId' => $method->getIdentifier(),
                'consumes' => ['application/json'],
                'produces' => ['application/json'],
                'parameters' => [
                    [
                        'in' => 'body',
                        'name' => 'JsonRpc request',
                        'required' => true,
                        'schema' => $this->requestDocTransformer->normalize($method)
                    ]
                ],
                'responses' => [
                    '200' => [
                        'description' => 'JSON-RPC response',
                        'schema' => $this->responseDocNormalizer->normalize($method),
                    ]
                ]
            ]
        ;
    }