protected function prepareIndexes()
    {
        $originalState = SearchVariant::current_state();
        $dirtyIndexes = array();
        $dirty = $this->getSource();
        $indexes = FullTextSearch::get_indexes();
        foreach ($dirty as $base => $statefulids) {
            if (!$statefulids) {
                continue;
            }

            foreach ($statefulids as $statefulid) {
                $state = $statefulid['state'];
                $ids = $statefulid['ids'];

                SearchVariant::activate_state($state);

                // Ensure that indexes for all new / updated objects are included
                $objs = DataObject::get($base)->byIDs(array_keys($ids));
                foreach ($objs as $obj) {
                    foreach ($ids[$obj->ID] as $index) {
                        if (!$indexes[$index]->variantStateExcluded($state)) {
                            $indexes[$index]->add($obj);
                            $dirtyIndexes[$index] = $indexes[$index];
                        }
                    }
                    unset($ids[$obj->ID]);
                }

                // Generate list of records that do not exist and should be removed
                foreach ($ids as $id => $fromindexes) {
                    foreach ($fromindexes as $index) {
                        if (!$indexes[$index]->variantStateExcluded($state)) {
                            $indexes[$index]->delete($base, $id, $state);
                            $dirtyIndexes[$index] = $indexes[$index];
                        }
                    }
                }
            }
        }
        
        SearchVariant::activate_state($originalState);
        return $dirtyIndexes;
    }
protected function prepareIndexes()
    {
        $originalState = SearchVariant::current_state();
        $dirtyIndexes = array();
        $dirty = $this->getSource();
        $indexes = FullTextSearch::get_indexes();
        foreach ($dirty as $base => $statefulids) {
            if (!$statefulids) {
                continue;
            }

            foreach ($statefulids as $statefulid) {
                $state = $statefulid['state'];
                $ids = $statefulid['ids'];

                SearchVariant::activate_state($state);

                // Ensure that indexes for all new / updated objects are included
                $objs = DataObject::get($base)->byIDs(array_keys($ids));
                foreach ($objs as $obj) {
                    foreach ($ids[$obj->ID] as $index) {
                        if (!$indexes[$index]->variantStateExcluded($state)) {
                            $indexes[$index]->add($obj);
                            $dirtyIndexes[$index] = $indexes[$index];
                        }
                    }
                    unset($ids[$obj->ID]);
                }

                // Generate list of records that do not exist and should be removed
                foreach ($ids as $id => $fromindexes) {
                    foreach ($fromindexes as $index) {
                        if (!$indexes[$index]->variantStateExcluded($state)) {
                            $indexes[$index]->delete($base, $id, $state);
                            $dirtyIndexes[$index] = $indexes[$index];
                        }
                    }
                }
            }
        }
        
        SearchVariant::activate_state($originalState);
        return $dirtyIndexes;
    }
protected function prepareIndexes ( ) { $ originalState = SearchVariant :: current_state ( ) ; $ dirtyIndexes = array ( ) ; $ dirty = $ this -> getSource ( ) ; $ indexes = FullTextSearch :: get_indexes ( ) ; foreach ( $ dirty as $ base => $ statefulids ) { if ( ! $ statefulids ) { continue ; } foreach ( $ statefulids as $ statefulid ) { $ state = $ statefulid [ 'state' ] ; $ ids = $ statefulid [ 'ids' ] ; SearchVariant :: activate_state ( $ state ) ; // Ensure that indexes for all new / updated objects are included $ objs = DataObject :: get ( $ base ) -> byIDs ( array_keys ( $ ids ) ) ; foreach ( $ objs as $ obj ) { foreach ( $ ids [ $ obj -> ID ] as $ index ) { if ( ! $ indexes [ $ index ] -> variantStateExcluded ( $ state ) ) { $ indexes [ $ index ] -> add ( $ obj ) ; $ dirtyIndexes [ $ index ] = $ indexes [ $ index ] ; } } unset ( $ ids [ $ obj -> ID ] ) ; } // Generate list of records that do not exist and should be removed foreach ( $ ids as $ id => $ fromindexes ) { foreach ( $ fromindexes as $ index ) { if ( ! $ indexes [ $ index ] -> variantStateExcluded ( $ state ) ) { $ indexes [ $ index ] -> delete ( $ base , $ id , $ state ) ; $ dirtyIndexes [ $ index ] = $ indexes [ $ index ] ; } } } } } SearchVariant :: activate_state ( $ originalState ) ; return $ dirtyIndexes ; }
Generates the list of indexes to process for the dirty items

@return array
Generates the list of indexes to process for the dirty items