src/OaiPmh/Harvester.php
public function launch()
    {
        // Normalize sets setting to an array:
        $sets = (array)$this->set;
        if (empty($sets)) {
            $sets = [null];
        }

        // Load last state, if applicable (used to recover from server failure).
        if ($state = $this->stateManager->loadState()) {
            $this->write("Found saved state; attempting to resume.\n");
            list($resumeSet, $resumeToken, $this->startDate) = $state;
        }

        // Loop through all of the selected sets:
        foreach ($sets as $set) {
            // If we're resuming and there are multiple sets, find the right one.
            if (isset($resumeToken) && $resumeSet != $set) {
                continue;
            }

            // If we have a token to resume from, pick up there now...
            if (isset($resumeToken)) {
                $token = $resumeToken;
                unset($resumeToken);
            } else {
                // ...otherwise, start harvesting at the requested date:
                $token = $this->getRecordsByDate(
                    $this->startDate, $set, $this->harvestEndDate
                );
            }

            // Keep harvesting as long as a resumption token is provided:
            while ($token !== false) {
                // Save current state in case we need to resume later:
                $this->stateManager->saveState($set, $token, $this->startDate);
                $token = $this->getRecordsByToken($token);
            }
        }

        // If we made it this far, all was successful, so we should clean up
        // the stored state.
        $this->stateManager->clearState();
    }
public function launch()
    {
        // Normalize sets setting to an array:
        $sets = (array)$this->set;
        if (empty($sets)) {
            $sets = [null];
        }

        // Load last state, if applicable (used to recover from server failure).
        if ($state = $this->stateManager->loadState()) {
            $this->write("Found saved state; attempting to resume.\n");
            list($resumeSet, $resumeToken, $this->startDate) = $state;
        }

        // Loop through all of the selected sets:
        foreach ($sets as $set) {
            // If we're resuming and there are multiple sets, find the right one.
            if (isset($resumeToken) && $resumeSet != $set) {
                continue;
            }

            // If we have a token to resume from, pick up there now...
            if (isset($resumeToken)) {
                $token = $resumeToken;
                unset($resumeToken);
            } else {
                // ...otherwise, start harvesting at the requested date:
                $token = $this->getRecordsByDate(
                    $this->startDate, $set, $this->harvestEndDate
                );
            }

            // Keep harvesting as long as a resumption token is provided:
            while ($token !== false) {
                // Save current state in case we need to resume later:
                $this->stateManager->saveState($set, $token, $this->startDate);
                $token = $this->getRecordsByToken($token);
            }
        }

        // If we made it this far, all was successful, so we should clean up
        // the stored state.
        $this->stateManager->clearState();
    }
public function launch ( ) { // Normalize sets setting to an array: $ sets = ( array ) $ this -> set ; if ( empty ( $ sets ) ) { $ sets = [ null ] ; } // Load last state, if applicable (used to recover from server failure). if ( $ state = $ this -> stateManager -> loadState ( ) ) { $ this -> write ( "Found saved state; attempting to resume.\n" ) ; list ( $ resumeSet , $ resumeToken , $ this -> startDate ) = $ state ; } // Loop through all of the selected sets: foreach ( $ sets as $ set ) { // If we're resuming and there are multiple sets, find the right one. if ( isset ( $ resumeToken ) && $ resumeSet != $ set ) { continue ; } // If we have a token to resume from, pick up there now... if ( isset ( $ resumeToken ) ) { $ token = $ resumeToken ; unset ( $ resumeToken ) ; } else { // ...otherwise, start harvesting at the requested date: $ token = $ this -> getRecordsByDate ( $ this -> startDate , $ set , $ this -> harvestEndDate ) ; } // Keep harvesting as long as a resumption token is provided: while ( $ token !== false ) { // Save current state in case we need to resume later: $ this -> stateManager -> saveState ( $ set , $ token , $ this -> startDate ) ; $ token = $ this -> getRecordsByToken ( $ token ) ; } } // If we made it this far, all was successful, so we should clean up // the stored state. $ this -> stateManager -> clearState ( ) ; }
Harvest all available documents.

@return void
Harvest all available documents .