/** * Compose and send wrapper for \XLite\View\Mailer::compose() * * @param string $type Email type. It defines the additional specific changes of the email data * (see prepareFrom and other methods) * @param string $from Email FROM * @param string $to Email TO * @param string $dir Directory where mail templates are located * @param array $customHeaders Array of custom mail headers OPTIONAL * @param boolean $doSend Flag: if true - send email immediately OPTIONAL * @param string $interface Interface to compile mail templates (skin name: customer, admin or mail) OPTIONAL * @param string $languageCode Language code OPTIONAL * * @return boolean */ protected static function compose($type, $from, $to, $dir, $customHeaders = array(), $doSend = true, $interface = \XLite::CUSTOMER_INTERFACE, $languageCode = '') { $result = false; static::$errorMessage = null; if (static::isNotificationEnabled($dir, $interface)) { static::getMailer()->compose(static::prepareFrom($type, $from), static::prepareTo($type, $to), static::prepareDir($type, $dir), static::prepareCustomHeaders($type, $customHeaders), $interface, $languageCode); if ($doSend) { $result = static::getMailer()->send(); } } if (!$result && static::getMailer()->getLastErrorMessage()) { static::$errorMessage = static::getMailer()->getLastErrorMessage(); } return $result; }
/** * Evaluate if the we can search for posts. * * @return bool */ public static function isAvailable() { if (static::$isAvailable !== null) { return static::$isAvailable; } $client = new Client(); try { static::$isAvailable = (bool) self::indicesExists($client->getIndexName()); } catch (Exception $e) { static::$errorMessage = $e->getMessage(); static::$isAvailable = false; } return static::$isAvailable; }
/** * Get error message * * @return string */ protected function getErrorMessage() { if (is_null(static::$errorMessage)) { static::$errorMessage = \XLite\Core\Session::getInstance()->error_message; \XLite\Core\Session::getInstance()->error_message = null; } return static::$errorMessage; }