本文整理匯總了PHP中xPDO::getService方法的典型用法代碼示例。如果您正苦於以下問題:PHP xPDO::getService方法的具體用法?PHP xPDO::getService怎麽用?PHP xPDO::getService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xPDO
的用法示例。
在下文中一共展示了xPDO::getService方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sendEmail
/**
* Send an email
*
* @param string $subject The subject of the email
* @param string $body The body of the email to send
* @param string $to The email address to send to
* @return boolean
*/
protected function sendEmail($subject, $body, $to)
{
if (!$this->_loadLexicon()) {
return false;
}
$this->xpdo->lexicon->load('quip:emails');
$this->xpdo->getService('mail', 'mail.modPHPMailer');
if (!$this->xpdo->mail) {
return false;
}
$emailFrom = $this->xpdo->context->getOption('quip.emailsFrom', $this->xpdo->context->getOption('emailsender'));
$emailReplyTo = $this->xpdo->context->getOption('quip.emailsReplyTo', $this->xpdo->context->getOption('emailsender'));
/* allow multiple to addresses */
if (!is_array($to)) {
$to = explode(',', $to);
}
$success = false;
foreach ($to as $emailAddress) {
if (empty($emailAddress) || strpos($emailAddress, '@') == false) {
continue;
}
$this->xpdo->mail->set(modMail::MAIL_BODY, $body);
$this->xpdo->mail->set(modMail::MAIL_FROM, $emailFrom);
$this->xpdo->mail->set(modMail::MAIL_FROM_NAME, $this->xpdo->context->getOption('quip.emails_from_name', 'Quip'));
$this->xpdo->mail->set(modMail::MAIL_SENDER, $emailFrom);
$this->xpdo->mail->set(modMail::MAIL_SUBJECT, $subject);
$this->xpdo->mail->address('to', $emailAddress);
$this->xpdo->mail->address('reply-to', $emailReplyTo);
$this->xpdo->mail->setHTML(true);
$success = $this->xpdo->mail->send();
$this->xpdo->mail->reset();
}
return $success;
}
示例2: sendEmail
/**
* Send an email to the user
*
* @param string $message The body of the email
* @param array $options An array of options
* @return boolean True if successful
*/
public function sendEmail($message, array $options = array())
{
if (!$this->xpdo instanceof modX) {
return false;
}
$profile = $this->getOne('Profile');
if (empty($profile)) {
return false;
}
$this->xpdo->getService('mail', 'mail.modPHPMailer');
if (!$this->xpdo->mail) {
return false;
}
$this->xpdo->mail->set(modMail::MAIL_BODY, $message);
$this->xpdo->mail->set(modMail::MAIL_FROM, $this->xpdo->getOption('from', $options, $this->xpdo->getOption('emailsender')));
$this->xpdo->mail->set(modMail::MAIL_FROM_NAME, $this->xpdo->getOption('fromName', $options, $this->xpdo->getOption('site_name')));
$this->xpdo->mail->set(modMail::MAIL_SENDER, $this->xpdo->getOption('sender', $options, $this->xpdo->getOption('emailsender')));
$this->xpdo->mail->set(modMail::MAIL_SUBJECT, $this->xpdo->getOption('subject', $options, $this->xpdo->getOption('emailsubject')));
$this->xpdo->mail->address('to', $profile->get('email'), $profile->get('fullname'));
$this->xpdo->mail->address('reply-to', $this->xpdo->getOption('sender', $options, $this->xpdo->getOption('emailsender')));
$this->xpdo->mail->setHTML($this->xpdo->getOption('html', $options, true));
$sent = $this->xpdo->mail->send();
$this->xpdo->mail->reset();
return $sent;
}
示例3: getClient
/**
* Get the client responsible for communicating with the provider.
*
* @return modRestClient|bool A REST client instance, or FALSE.
*/
public function getClient()
{
if (empty($this->xpdo->rest)) {
$this->xpdo->getService('rest', 'rest.modRestClient');
$loaded = $this->xpdo->rest->getConnection();
if (!$loaded) {
return false;
}
}
return $this->xpdo->rest;
}