Exemple #1
0
 /**
  * We adjusted the constructor to accept both an array and an object.
  */
 public function __construct($mixed)
 {
     // we still have to support the code in \Zend\Queue\Queue::receive that
     // passes in an array
     if (is_array($mixed)) {
         parent::__construct($mixed);
     } elseif (is_object($mixed)) {
         $this->setBody($mixed);
         $this->_connected = false;
     }
 }
Exemple #2
0
 /**
  * Constructor
  *
  * The constructor should be an array of options.
  *
  * If the option 'data' is provided, and is an instance of \ZendAPI_Job,
  * that object will be used as the internal job; if that option is not a
  * \ZendAPI_Job instance, an exception will be thrown.
  *
  * Alternately, you may specify the 'script' parameter, which should be a
  * JobQueue script the job will request. A new \ZendAPI_Job object will then
  * be created using that script and any options you provide.
  *
  * @param  array $options
  * @return void
  * @throws \Zend\Queue\Exception
  */
 public function __construct(array $options = array())
 {
     if (isset($options['data'])) {
         if (!$options['data'] instanceof \ZendAPI_Job) {
             throw new Queue\Exception('Data must be an instance of \\ZendAPI_Job');
         }
         $this->_job = $options['data'];
         parent::__construct($this->_job->getProperties());
     } else {
         parent::__construct($options);
         if (!isset($options['script'])) {
             throw new Queue\Exception('The script is mandatory data');
         }
         $this->_job = new \ZendAPI_Job($options['script']);
         $this->_setJobProperties();
     }
 }