public function processDocument(Document $document, array $processingConfiguration) {
        foreach ($processingConfiguration as $fieldName => $instruction) {
            $fieldValue = $document[$fieldName] ?? false;
            $isSingleValueField = false;

            if ($fieldValue !== false) {
                if (!is_array($fieldValue)) {
                    // turn single value field into multi value field
                    $fieldValue = [$fieldValue];
                    $isSingleValueField = true;
                }

                switch ($instruction) {
                    case 'timestampToUtcIsoDate':
                        /** @var $processor TimestampToUtcIsoDate */
                        $processor = GeneralUtility::makeInstance(TimestampToUtcIsoDate::class);
                        $fieldValue = $processor->process($fieldValue);
                        break;
                    case 'timestampToIsoDate':
                        /** @var $processor TimestampToIsoDate */
                        $processor = GeneralUtility::makeInstance(TimestampToIsoDate::class);
                        $fieldValue = $processor->process($fieldValue);
                        break;
                    case 'pathToHierarchy':
                        /** @var $processor PathToHierarchy */
                        $processor = GeneralUtility::makeInstance(PathToHierarchy::class);
                        $fieldValue = $processor->process($fieldValue);
                        break;
                    case 'pageUidToHierarchy':
                        /** @var $processor PageUidToHierarchy */
                        $processor = GeneralUtility::makeInstance(PageUidToHierarchy::class);
                        $fieldValue = $processor->process($fieldValue);
                        break;
                    case 'categoryUidToHierarchy':
                        /** @var $processor CategoryUidToHierarchy */
                        $processor = GeneralUtility::makeInstance(CategoryUidToHierarchy::class);
                        $fieldValue = $processor->process($fieldValue);
                        break;
                    case 'uppercase':
                        $fieldValue = array_map('mb_strtoupper', $fieldValue);
                        break;
                }

                if ($isSingleValueField) {
                    // turn multi value field back into single value field
                    $fieldValue = $fieldValue[0];
                }

                $document->setField($fieldName, $fieldValue);
            }
        }
    }
public function processDocument(Document $document, array $processingConfiguration) {
        foreach ($processingConfiguration as $fieldName => $instruction) {
            $fieldValue = $document[$fieldName] ?? false;
            $isSingleValueField = false;

            if ($fieldValue !== false) {
                if (!is_array($fieldValue)) {
                    // turn single value field into multi value field
                    $fieldValue = [$fieldValue];
                    $isSingleValueField = true;
                }

                switch ($instruction) {
                    case 'timestampToUtcIsoDate':
                        /** @var $processor TimestampToUtcIsoDate */
                        $processor = GeneralUtility::makeInstance(TimestampToUtcIsoDate::class);
                        $fieldValue = $processor->process($fieldValue);
                        break;
                    case 'timestampToIsoDate':
                        /** @var $processor TimestampToIsoDate */
                        $processor = GeneralUtility::makeInstance(TimestampToIsoDate::class);
                        $fieldValue = $processor->process($fieldValue);
                        break;
                    case 'pathToHierarchy':
                        /** @var $processor PathToHierarchy */
                        $processor = GeneralUtility::makeInstance(PathToHierarchy::class);
                        $fieldValue = $processor->process($fieldValue);
                        break;
                    case 'pageUidToHierarchy':
                        /** @var $processor PageUidToHierarchy */
                        $processor = GeneralUtility::makeInstance(PageUidToHierarchy::class);
                        $fieldValue = $processor->process($fieldValue);
                        break;
                    case 'categoryUidToHierarchy':
                        /** @var $processor CategoryUidToHierarchy */
                        $processor = GeneralUtility::makeInstance(CategoryUidToHierarchy::class);
                        $fieldValue = $processor->process($fieldValue);
                        break;
                    case 'uppercase':
                        $fieldValue = array_map('mb_strtoupper', $fieldValue);
                        break;
                }

                if ($isSingleValueField) {
                    // turn multi value field back into single value field
                    $fieldValue = $fieldValue[0];
                }

                $document->setField($fieldName, $fieldValue);
            }
        }
    }
public function processDocument ( Document $ document , array $ processingConfiguration ) { foreach ( $ processingConfiguration as $ fieldName => $ instruction ) { $ fieldValue = $ document [ $ fieldName ] ?? false ; $ isSingleValueField = false ; if ( $ fieldValue !== false ) { if ( ! is_array ( $ fieldValue ) ) { // turn single value field into multi value field $ fieldValue = [ $ fieldValue ] ; $ isSingleValueField = true ; } switch ( $ instruction ) { case 'timestampToUtcIsoDate' : /** @var $processor TimestampToUtcIsoDate */ $ processor = GeneralUtility :: makeInstance ( TimestampToUtcIsoDate :: class ) ; $ fieldValue = $ processor -> process ( $ fieldValue ) ; break ; case 'timestampToIsoDate' : /** @var $processor TimestampToIsoDate */ $ processor = GeneralUtility :: makeInstance ( TimestampToIsoDate :: class ) ; $ fieldValue = $ processor -> process ( $ fieldValue ) ; break ; case 'pathToHierarchy' : /** @var $processor PathToHierarchy */ $ processor = GeneralUtility :: makeInstance ( PathToHierarchy :: class ) ; $ fieldValue = $ processor -> process ( $ fieldValue ) ; break ; case 'pageUidToHierarchy' : /** @var $processor PageUidToHierarchy */ $ processor = GeneralUtility :: makeInstance ( PageUidToHierarchy :: class ) ; $ fieldValue = $ processor -> process ( $ fieldValue ) ; break ; case 'categoryUidToHierarchy' : /** @var $processor CategoryUidToHierarchy */ $ processor = GeneralUtility :: makeInstance ( CategoryUidToHierarchy :: class ) ; $ fieldValue = $ processor -> process ( $ fieldValue ) ; break ; case 'uppercase' : $ fieldValue = array_map ( 'mb_strtoupper' , $ fieldValue ) ; break ; } if ( $ isSingleValueField ) { // turn multi value field back into single value field $ fieldValue = $ fieldValue [ 0 ] ; } $ document -> setField ( $ fieldName , $ fieldValue ) ; } } }
modifies a document according to the given configuration

@param Document $document
@param array $processingConfiguration
modifies a document according to the given configuration