public
Last active

Zend_Queue background job abstract class

  • Download Gist
Job.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
<?php
/**
* Zend_Queue background job abstract class
*
* @author Bernard Baltrusaitis <bernard@runawaylover.info>
*/
abstract class My_Job
{
/**
*
* @var Zend_Queue
*/
protected $_queue = null;
/**
* Executes given job
*
* @return boolean true if job was successful
*/
abstract function job();
public function __construct(Zend_Queue $queue)
{
$this->_queue = $queue;
}
public function setOptions(array $options)
{
foreach ($options as $name => $value) {
$property = sprintf('_%s', $name);
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
}
}
/**
* Send job to queue
*
* @return Zend_Queue_Message
*/
public function execute()
{
return $this->_queue->send(serialize($this));
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.