Skip to content

Instantly share code, notes, and snippets.

@b-b3rn4rd
Created June 9, 2012 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b-b3rn4rd/2899315 to your computer and use it in GitHub Desktop.
Save b-b3rn4rd/2899315 to your computer and use it in GitHub Desktop.
Zend_Queue background job abstract class
<?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));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment