Пример #1
0
 /**
  * New messenger method:
  * Uses an expandable array of options and supports direct template rendering and subject prepending.
  *
  * @param array $message_options An array of message options.
  * @return bool|void
  */
 public static function send($message_options)
 {
     $di = \Phalcon\Di::getDefault();
     $config = $di->get('config');
     $default_options = array('reply_to' => NULL, 'delivery_date' => NULL, 'options' => NULL);
     $options = array_merge($default_options, $message_options);
     // Render the template as the message if a template is specified.
     if (isset($options['template'])) {
         $previous_sp_setting = \DF\Url::getSchemePrefixSetting();
         \DF\Url::forceSchemePrefix(TRUE);
         $view = \DF\Phalcon\View::getView(array('views_dir' => 'messages', 'layouts_dir' => '../templates', 'layout' => 'message'));
         $view->subject = $options['subject'];
         $view->setVars((array) $options['vars']);
         $options['message'] = $view->getRender('', $options['template']);
         \DF\Url::forceSchemePrefix($previous_sp_setting);
     } else {
         if (isset($options['body']) && !isset($options['message'])) {
             $options['message'] = $options['body'];
             unset($options['body']);
         }
     }
     // Append the system name as a prefix to the message.
     if (!isset($options['no_prefix']) || $options['no_prefix'] == FALSE) {
         $app_name = $config->application->name;
         $options['subject'] = $app_name . ': ' . $options['subject'];
     }
     return self::sendMail($options);
 }