public function applyHtmlSpecialCharsOnAllFields(array $documents)
    {
        $trustedSolrFields = $this->typoScriptConfiguration->getSearchTrustedFieldsArray();

        foreach ($documents as $key => $document) {
            $fieldNames = array_keys($document->getFields() ?? []);

            foreach ($fieldNames as $fieldName) {
                if (is_array($trustedSolrFields) && in_array($fieldName, $trustedSolrFields)) {
                    // we skip this field, since it was marked as secure
                    continue;
                }

                $value = $this->applyHtmlSpecialCharsOnSingleFieldValue($document[$fieldName]);
                $document->setField($fieldName, $value);
            }

            $documents[$key] = $document;
        }

        return $documents;
    }
public function applyHtmlSpecialCharsOnAllFields(array $documents)
    {
        $trustedSolrFields = $this->typoScriptConfiguration->getSearchTrustedFieldsArray();

        foreach ($documents as $key => $document) {
            $fieldNames = array_keys($document->getFields() ?? []);

            foreach ($fieldNames as $fieldName) {
                if (is_array($trustedSolrFields) && in_array($fieldName, $trustedSolrFields)) {
                    // we skip this field, since it was marked as secure
                    continue;
                }

                $value = $this->applyHtmlSpecialCharsOnSingleFieldValue($document[$fieldName]);
                $document->setField($fieldName, $value);
            }

            $documents[$key] = $document;
        }

        return $documents;
    }
public function applyHtmlSpecialCharsOnAllFields ( array $ documents ) { $ trustedSolrFields = $ this -> typoScriptConfiguration -> getSearchTrustedFieldsArray ( ) ; foreach ( $ documents as $ key => $ document ) { $ fieldNames = array_keys ( $ document -> getFields ( ) ?? [ ] ) ; foreach ( $ fieldNames as $ fieldName ) { if ( is_array ( $ trustedSolrFields ) && in_array ( $ fieldName , $ trustedSolrFields ) ) { // we skip this field, since it was marked as secure continue ; } $ value = $ this -> applyHtmlSpecialCharsOnSingleFieldValue ( $ document [ $ fieldName ] ) ; $ document -> setField ( $ fieldName , $ value ) ; } $ documents [ $ key ] = $ document ; } return $ documents ; }
This method is used to apply htmlspecialchars on all document fields that
are not configured to be secure. Secure mean that we know where the content is coming from.

@param Document[] $documents
@return Document[]
This method is used to apply htmlspecialchars on all document fields that are not configured to be secure . Secure mean that we know where the content is coming from .