private function buildPageMap(int $mainRoot, int $otherRoot, array &$map, array &$inverse): array
    {
        // Root pages are mapped to each other.
        $map[$otherRoot]    = $mainRoot;
        $inverse[$mainRoot] = $otherRoot;

        // Now fetch all other.
        $isMain      = $mainRoot === $otherRoot;
        $lookupQueue = [$otherRoot];
        do {
            // Fetch children of parents in queue.
            $children = $this->database->getPagesByPidList($lookupQueue);
            // Nothing to do anymore, break it.
            if (empty($children)) {
                break;
            }

            // Reset pid list - we have the children.
            $lookupQueue = [];

            foreach ($children as $index => $child) {
                $childId = (int) $child['id'];
                $main    = $isMain ? $childId : (int) $child['languageMain'];
                // Try to determine automatically.
                if (!$isMain && empty($main)) {
                    if (null === ($main = $this->determineMapFor($index, (int) $child['pid'], $map))) {
                        $this->logger->warning(
                            'Page {id} has no fallback set and unable to determine automatically. Page skipped.',
                            ['id' => $childId]
                        );
                        continue;
                    }

                    $this->logger->warning(
                        'Page {id} (index: {index}) has no fallback set, expect problems, I guess it is {guessed}',
                        ['id' => $childId, 'index' => $index, 'guessed' => $main]
                    );
                }

                $map[$childId]  = $main;
                $inverse[$main] = $childId;

                // Keep type for being able to filter unknown pages in i.e. articles.
                $this->types[$childId] = $child['type'];

                $lookupQueue[] = $childId;
            }
        } while (true);

        return $map;
    }
private function buildPageMap(int $mainRoot, int $otherRoot, array &$map, array &$inverse): array
    {
        // Root pages are mapped to each other.
        $map[$otherRoot]    = $mainRoot;
        $inverse[$mainRoot] = $otherRoot;

        // Now fetch all other.
        $isMain      = $mainRoot === $otherRoot;
        $lookupQueue = [$otherRoot];
        do {
            // Fetch children of parents in queue.
            $children = $this->database->getPagesByPidList($lookupQueue);
            // Nothing to do anymore, break it.
            if (empty($children)) {
                break;
            }

            // Reset pid list - we have the children.
            $lookupQueue = [];

            foreach ($children as $index => $child) {
                $childId = (int) $child['id'];
                $main    = $isMain ? $childId : (int) $child['languageMain'];
                // Try to determine automatically.
                if (!$isMain && empty($main)) {
                    if (null === ($main = $this->determineMapFor($index, (int) $child['pid'], $map))) {
                        $this->logger->warning(
                            'Page {id} has no fallback set and unable to determine automatically. Page skipped.',
                            ['id' => $childId]
                        );
                        continue;
                    }

                    $this->logger->warning(
                        'Page {id} (index: {index}) has no fallback set, expect problems, I guess it is {guessed}',
                        ['id' => $childId, 'index' => $index, 'guessed' => $main]
                    );
                }

                $map[$childId]  = $main;
                $inverse[$main] = $childId;

                // Keep type for being able to filter unknown pages in i.e. articles.
                $this->types[$childId] = $child['type'];

                $lookupQueue[] = $childId;
            }
        } while (true);

        return $map;
    }
private function buildPageMap ( int $ mainRoot , int $ otherRoot , array & $ map , array & $ inverse ) : array { // Root pages are mapped to each other. $ map [ $ otherRoot ] = $ mainRoot ; $ inverse [ $ mainRoot ] = $ otherRoot ; // Now fetch all other. $ isMain = $ mainRoot === $ otherRoot ; $ lookupQueue = [ $ otherRoot ] ; do { // Fetch children of parents in queue. $ children = $ this -> database -> getPagesByPidList ( $ lookupQueue ) ; // Nothing to do anymore, break it. if ( empty ( $ children ) ) { break ; } // Reset pid list - we have the children. $ lookupQueue = [ ] ; foreach ( $ children as $ index => $ child ) { $ childId = ( int ) $ child [ 'id' ] ; $ main = $ isMain ? $ childId : ( int ) $ child [ 'languageMain' ] ; // Try to determine automatically. if ( ! $ isMain && empty ( $ main ) ) { if ( null === ( $ main = $ this -> determineMapFor ( $ index , ( int ) $ child [ 'pid' ] , $ map ) ) ) { $ this -> logger -> warning ( 'Page {id} has no fallback set and unable to determine automatically. Page skipped.' , [ 'id' => $ childId ] ) ; continue ; } $ this -> logger -> warning ( 'Page {id} (index: {index}) has no fallback set, expect problems, I guess it is {guessed}' , [ 'id' => $ childId , 'index' => $ index , 'guessed' => $ main ] ) ; } $ map [ $ childId ] = $ main ; $ inverse [ $ main ] = $ childId ; // Keep type for being able to filter unknown pages in i.e. articles. $ this -> types [ $ childId ] = $ child [ 'type' ] ; $ lookupQueue [ ] = $ childId ; } } while ( true ) ; return $ map ; }
Build a map for a language and returns the map from source to main.

@param int   $mainRoot  The main language root page.
@param int   $otherRoot The root page of the other language.
@param array $map       The mapping array to populate.
@param array $inverse   The inverse mapping.

@return int[]
Build a map for a language and returns the map from source to main .