Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $myFeed->startImport()
- public function startImport() {
- module_invoke_all('feeds_before_import', $this);
- $config = $this->importer->getConfig();
- if ($config['process_in_background']) {
- $this->startBackgroundJob('import');
- }
- else {
- $this->startBatchAPIJob(t('Importing'), 'import');
- }
- }
- /**
- * Background job helper. Starts a background job using Job Scheduler.
- *
- * Execute the first batch chunk of a background job on the current page load,
- * moves the rest of the job processing to a cron powered background job.
- *
- * Executing the first batch chunk is important, otherwise, when a user
- * submits a source for import or clearing, we will leave her without any
- * visual indicators of an ongoing job.
- *
- * @see FeedsSource::startImport().
- * @see FeedsSource::startClear().
- *
- * @param $method
- * Method to execute on importer; one of 'import' or 'clear'.
- *
- * @throws Exception $e
- */
- protected function startBackgroundJob($method) {
- if (FEEDS_BATCH_COMPLETE != $this->$method()) {
- $job = array(
- 'type' => $this->id,
- 'id' => $this->feed_nid,
- 'period' => 0,
- 'periodic' => FALSE,
- );
- JobScheduler::get("feeds_source_{$method}")->set($job);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement