diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-23 20:43:51 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-23 20:43:51 -0400 |
commit | 8314c99b56e66c2b86dd32432bcf5ed94a3ece02 (patch) | |
tree | 564ed1c270a0907efb5be8da1d971526cd235c6e /app/Job/EmailJob.php | |
parent | dc6176fca23ea697380ab115aea976fa8271f047 (diff) |
Added QueueManager to process background jobs
Diffstat (limited to 'app/Job/EmailJob.php')
-rw-r--r-- | app/Job/EmailJob.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/app/Job/EmailJob.php b/app/Job/EmailJob.php new file mode 100644 index 00000000..9293a1d4 --- /dev/null +++ b/app/Job/EmailJob.php @@ -0,0 +1,54 @@ +<?php + +namespace Kanboard\Job; + +/** + * Class EmailJob + * + * @package Kanboard\Job + * @author Frederic Guillot + */ +class EmailJob extends BaseJob +{ + /** + * Set job parameters + * + * @access public + * @param string $email + * @param string $name + * @param string $subject + * @param string $html + * @param string $author + * @return $this + */ + public function withParams($email, $name, $subject, $html, $author) + { + $this->jobParams = array($email, $name, $subject, $html, $author); + return $this; + } + + /** + * Execute job + * + * @access public + * @param string $email + * @param string $name + * @param string $subject + * @param string $html + * @param string $author + */ + public function execute($email, $name, $subject, $html, $author) + { + $this->logger->debug(__METHOD__.' Sending email to '.$email.' via '.MAIL_TRANSPORT); + $startTime = microtime(true); + + $this->emailClient + ->getTransport(MAIL_TRANSPORT) + ->sendEmail($email, $name, $subject, $html, $author) + ; + + if (DEBUG) { + $this->logger->debug('Email sent in '.round(microtime(true) - $startTime, 6).' seconds'); + } + } +} |