-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for queued jobs module
- Loading branch information
Mark Guinn
committed
May 9, 2016
1 parent
6cd283b
commit cc5e938
Showing
4 changed files
with
118 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/** | ||
* If the queued jobs module is installed, this will be used for offline processing of Zip files. | ||
* | ||
* @author Mark Guinn <mark@adaircreative.com> | ||
* @date 05.09.2016 | ||
* @package shop_downloadable | ||
*/ | ||
if (!interface_exists('QueuedJob')) { | ||
return; | ||
} | ||
|
||
class FilePrepQueuedJob extends AbstractQueuedJob implements QueuedJob | ||
{ | ||
/** | ||
* The QueuedJob queue to use when processing updates | ||
* @config | ||
* @var int | ||
*/ | ||
private static $reindex_queue = 2; // QueuedJob::QUEUED; | ||
|
||
|
||
/** | ||
* @param DownloadTempFile $object | ||
*/ | ||
public function __construct($object) | ||
{ | ||
$this->setObject($object); | ||
} | ||
|
||
|
||
/** | ||
* Helper method | ||
*/ | ||
public function triggerProcessing() | ||
{ | ||
singleton('QueuedJobService')->queueJob($this); | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getTitle() | ||
{ | ||
/** @var DownloadTempFile $obj */ | ||
$obj = $this->getObject(); | ||
return "Prep File For Download: " . ($obj ? $obj->getFriendlyName() : '???'); | ||
} | ||
|
||
|
||
/** | ||
* Reprocess any needed fields | ||
*/ | ||
public function process() | ||
{ | ||
ini_set('memory_limit', '1G'); | ||
|
||
/** @var DownloadTempFile $obj */ | ||
$obj = $this->getObject(); | ||
$obj->process(); | ||
$this->isComplete = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters