public function process()
    {
        $chunkSize = self::config()->get('chunk_size');
        $count = 0;

        // Remove any URLs which have already been processed
        if ($this->jobData->ProcessedURLs) {
            $this->jobData->URLsToProcess = array_diff_key(
                $this->jobData->URLsToProcess,
                $this->jobData->ProcessedURLs
            );
        }

        foreach ($this->jobData->URLsToProcess as $url => $priority) {
            if (++$count > $chunkSize) {
                break;
            }
            $meta = Publisher::singleton()->publishURL($url, true);
            if (!empty($meta['success'])) {
                $this->jobData->ProcessedURLs[$url] = $url;
                unset($this->jobData->URLsToProcess[$url]);
            }
        }
        if (empty($this->jobData->URLsToProcess)) {
            $trimSlashes = function ($value) {
                return trim($value, '/');
            };
            $this->jobData->publishedURLs = array_map($trimSlashes, Publisher::singleton()->getPublishedURLs());
            $this->jobData->ProcessedURLs = array_map($trimSlashes, $this->jobData->ProcessedURLs);
            $this->jobData->URLsToCleanUp = array_diff($this->jobData->publishedURLs, $this->jobData->ProcessedURLs);

            foreach ($this->jobData->URLsToCleanUp as $staleURL) {
                $purgeMeta = Publisher::singleton()->purgeURL($staleURL);
                if (!empty($purgeMeta['success'])) {
                    unset($this->jobData->URLsToCleanUp[$staleURL]);
                }
            }
        };
        $this->isComplete = empty($this->jobData->URLsToProcess) && empty($this->jobData->URLsToCleanUp);
    }
public function process()
    {
        $chunkSize = self::config()->get('chunk_size');
        $count = 0;

        // Remove any URLs which have already been processed
        if ($this->jobData->ProcessedURLs) {
            $this->jobData->URLsToProcess = array_diff_key(
                $this->jobData->URLsToProcess,
                $this->jobData->ProcessedURLs
            );
        }

        foreach ($this->jobData->URLsToProcess as $url => $priority) {
            if (++$count > $chunkSize) {
                break;
            }
            $meta = Publisher::singleton()->publishURL($url, true);
            if (!empty($meta['success'])) {
                $this->jobData->ProcessedURLs[$url] = $url;
                unset($this->jobData->URLsToProcess[$url]);
            }
        }
        if (empty($this->jobData->URLsToProcess)) {
            $trimSlashes = function ($value) {
                return trim($value, '/');
            };
            $this->jobData->publishedURLs = array_map($trimSlashes, Publisher::singleton()->getPublishedURLs());
            $this->jobData->ProcessedURLs = array_map($trimSlashes, $this->jobData->ProcessedURLs);
            $this->jobData->URLsToCleanUp = array_diff($this->jobData->publishedURLs, $this->jobData->ProcessedURLs);

            foreach ($this->jobData->URLsToCleanUp as $staleURL) {
                $purgeMeta = Publisher::singleton()->purgeURL($staleURL);
                if (!empty($purgeMeta['success'])) {
                    unset($this->jobData->URLsToCleanUp[$staleURL]);
                }
            }
        };
        $this->isComplete = empty($this->jobData->URLsToProcess) && empty($this->jobData->URLsToCleanUp);
    }
public function process ( ) { $ chunkSize = self :: config ( ) -> get ( 'chunk_size' ) ; $ count = 0 ; // Remove any URLs which have already been processed if ( $ this -> jobData -> ProcessedURLs ) { $ this -> jobData -> URLsToProcess = array_diff_key ( $ this -> jobData -> URLsToProcess , $ this -> jobData -> ProcessedURLs ) ; } foreach ( $ this -> jobData -> URLsToProcess as $ url => $ priority ) { if ( ++ $ count > $ chunkSize ) { break ; } $ meta = Publisher :: singleton ( ) -> publishURL ( $ url , true ) ; if ( ! empty ( $ meta [ 'success' ] ) ) { $ this -> jobData -> ProcessedURLs [ $ url ] = $ url ; unset ( $ this -> jobData -> URLsToProcess [ $ url ] ) ; } } if ( empty ( $ this -> jobData -> URLsToProcess ) ) { $ trimSlashes = function ( $ value ) { return trim ( $ value , '/' ) ; } ; $ this -> jobData -> publishedURLs = array_map ( $ trimSlashes , Publisher :: singleton ( ) -> getPublishedURLs ( ) ) ; $ this -> jobData -> ProcessedURLs = array_map ( $ trimSlashes , $ this -> jobData -> ProcessedURLs ) ; $ this -> jobData -> URLsToCleanUp = array_diff ( $ this -> jobData -> publishedURLs , $ this -> jobData -> ProcessedURLs ) ; foreach ( $ this -> jobData -> URLsToCleanUp as $ staleURL ) { $ purgeMeta = Publisher :: singleton ( ) -> purgeURL ( $ staleURL ) ; if ( ! empty ( $ purgeMeta [ 'success' ] ) ) { unset ( $ this -> jobData -> URLsToCleanUp [ $ staleURL ] ) ; } } } ; $ this -> isComplete = empty ( $ this -> jobData -> URLsToProcess ) && empty ( $ this -> jobData -> URLsToCleanUp ) ; }
Do some processing yourself!
Do some processing yourself!