/** * Perfom work. * * @param Opus_Job $job Job description and attached data. * @return array Array of Jobs to be newly created. */ public function work(Opus_Job $job) { $data = $job->getData(true); $message = $data['message']; $subject = $data['subject']; $users = $data['users']; $from = $this->_getFrom(); $fromName = $this->_getFromName(); if (!is_null($users) and !is_array($users)) { $users = array($users); } $recipient = array(); if ($this->lookupRecipients) { $this->_logger->debug(__CLASS__ . ': Resolving mail addresses for users = {"' . implode('", "', $users) . '"}'); $recipient = $this->getRecipients($users); } else { $recipient = $users; } // if (empty($recipient)) { // $this->_logger->info(__CLASS__ . ': No recipients avaiable. Mail canceled.'); // return true; // } $mailSendMail = new Opus_Mail_SendMail(); $this->_logger->info(__CLASS__ . ': Sending notification email...'); $this->_logger->debug(__CLASS__ . ': sender: ' . $from); $mailSendMail->sendMail($from, $fromName, $subject, $message, $recipient); return true; }
/** * Perfom work. * * @param Opus_Job $job Job description and attached data. * @return array Array of Jobs to be newly created. */ public function work(Opus_Job $job) { if ($job->getLabel() != $this->getActivationLabel()) { throw new Opus_Job_Worker_InvalidJobException($job->getLabel() . " is not a suitable job for this worker."); } $data = $job->getData(); if (!(is_object($data) && isset($data->xml) && !is_null($data->xml))) { throw new Opus_Job_Worker_InvalidJobException("Incomplete or missing data."); } if (null !== $this->_logger) { $this->_logger->debug("Importing Metadata:\n" . $data->xml); } $importer = new Opus_Util_MetadataImport($data->xml); $importer->run(); }
/** * Load a document from database and optional file(s) and index them, * or remove document from index (depending on job) * * @param Opus_Job $job Job description and attached data. * @return void */ public function work(Opus_Job $job) { // make sure we have the right job if ($job->getLabel() != $this->getActivationLabel()) { throw new Opus_Job_Worker_InvalidJobException($job->getLabel() . " is not a suitable job for this worker."); } $this->_job = $job; $data = $job->getData(); if (!(is_object($data) && isset($data->documentId) && isset($data->task))) { throw new Opus_Job_Worker_InvalidJobException("Incomplete or missing data."); } if (null !== $this->_logger) { $this->_logger->info('Indexing document with ID: ' . $data->documentId . '.'); } // create index document or remove index, depending on task if ($data->task === 'index') { $document = new Opus_Document($data->documentId); $this->getIndex()->addDocumentToEntryIndex($document)->commit(); } else { if ($data->task === 'remove') { $this->getIndex()->removeDocumentFromEntryIndexById($data->documentId)->commit(); } else { throw new Opus_Job_Worker_InvalidJobException("unknown task '{$data->task}'."); } } }