EventListener/PersistenceEventListener.php
/**
     * Calculates what the desired revisit factor should be.
     *
     * @param \Simgroep\ConcurrentSpiderBundle\PersistenceEvent $event
     */
Calculates what the desired revisit factor should be.
Calculates what the desired revisit factor should be .
public function onPrePersistDocument(PersistenceEvent $event)
    {
        $newDocument = $event->getDocument();
        $this->checkIfPageIsBlacklistedByKeywordOrPhrase($newDocument);
        $currentDocument = $this->indexer->findDocumentByUrl($newDocument['url'], $event->getMetadata());
        if (null === $currentDocument || $currentDocument['revisit_after'] == 0) {
            $newDocument['revisit_after'] = $this->defaultRevisitFactor;
            $expireDate = new DateTime();
            $expireDate->modify(sprintf('+%s minute', $newDocument['revisit_after']));
            $newDocument['revisit_expiration'] = $expireDate->format('Y-m-d\TH:i:s\Z');
            return ;
        }
        if ($this->createDocumentChecksum($currentDocument) === $this->createDocumentChecksum($newDocument)) {
            $this->increaseRevisitFactor($newDocument, $currentDocument['revisit_after']);
        } else {
            $this->decreaseRevisitFactor($newDocument, $currentDocument['revisit_after']);
        }
    }
public function onPrePersistDocument ( PersistenceEvent $ event ) { $ newDocument = $ event -> getDocument ( ) ; $ this -> checkIfPageIsBlacklistedByKeywordOrPhrase ( $ newDocument ) ; $ currentDocument = $ this -> indexer -> findDocumentByUrl ( $ newDocument [ 'url' ] , $ event -> getMetadata ( ) ) ; if ( null === $ currentDocument || $ currentDocument [ 'revisit_after' ] == 0 ) { $ newDocument [ 'revisit_after' ] = $ this -> defaultRevisitFactor ; $ expireDate = new DateTime ( ) ; $ expireDate -> modify ( sprintf ( '+%s minute' , $ newDocument [ 'revisit_after' ] ) ) ; $ newDocument [ 'revisit_expiration' ] = $ expireDate -> format ( 'Y-m-d\TH:i:s\Z' ) ; return ; } if ( $ this -> createDocumentChecksum ( $ currentDocument ) === $ this -> createDocumentChecksum ( $ newDocument ) ) { $ this -> increaseRevisitFactor ( $ newDocument , $ currentDocument [ 'revisit_after' ] ) ; } else { $ this -> decreaseRevisitFactor ( $ newDocument , $ currentDocument [ 'revisit_after' ] ) ; } }
Calculates what the desired revisit factor should be.
Calculates what the desired revisit factor should be .